Here's the rule:
83.4 Disallowed Goal – If the puck is shot into the attacking zone creating
a delayed off-side, the play shall be allowed to continue under the
normal clearing-the-zone rules. Should the puck, as a result of this
shot, enter the defending team’s goal, either directly or off the
goalkeeper, a player, the boards, the glass, a piece of equipment or
an official on the ice, the goal shall be disallowed as the original shot
was off-side. The fact that the attacking team may have cleared the
zone prior to the puck entering the goal has no bearing on this ruling.
The face-off will be conducted at the face-off spot in the zone closest
to the point of origin of the shot that gives the offending team the least
amount of territorial advantage.
The only way an attacking team can score a goal on a delayed off-
side situation is if the defending team shoots or puts the puck into
their own net without action or contact by the offending team.
Other than in situations involving a delayed off-side and the puck
entering the goal or a successful Coach’s Challenge (see Rule 38), no
goal can be disallowed after the fact for an off-side violation, except
for the human factor involved in blowing the whistle.