And here's the rule if there was not a pin in that situation. The offensive wrestler should get an "extra" near-fall point (so 3 NF ends up being 4NF) and he gets an additional point for the violation (grabbing the headgear).

The rule book does not require stoppage of the match for all illegal holds/actions and the official is allowed to correct such action without stopping the match if possible. This is a very common situation and is almost always handled this way, as others have noticed.