This is straight from the USA Hockey Rule book. There can be slight variations to this rule based on which rule book your league follows:
Rule 624 | Icing the Puck
(Note) For the purpose of this rule, the center line shall divide the rink in half and the point of last contact with the puck shall be used to determine whether a potential icing exists. “Icing the puck shall have been completed the instant the puck has completely crossed the goal line.
(a) When a player of a team shoots, bats with the hand or stick or deflects the puck from his own half of the ice completely beyond the goal line of the opposing team, play shall be stopped and a face-off shall take place at an end zone face-off spot in the defending zone of the offending team.
(Note) If a team ices the puck during a delayed whistle as a result of a foul committed by the opposing team, the ensuing face-off shall take place at a neutral zone face-off spot nearest the defending zone of the team icing the puck.
However, if the puck has entered the goal as a result of a legal action by the team shooting the puck, the goal shall be allowed.
(b) Icing shall be nullified if any of the following conditions have been met:
The offending team is shorthanded (below the on-ice numerical strength of their opponent) when the puck is shot. The determination is made at the time the penalty expires and if the puck was shot prior to the penalty time expiration, regardless as to the position of the penalized player, no icing shall be called.
The puck is shot by an attacking player and rebounds off of the body or the stick of a defending player on their defensive half of the center red line.
The puck travels the length of the ice as a result of either player participating in a face-off.
The puck touches any part, including stick, skates or body, of an opposing player prior to crossing the goal line.
If, in the opinion of the Linesman, an opposing player – except the goalkeeper – has an opportunity to play the puck, and has not done so, prior to the puck crossing the goal line.