Straight out of the NCAA rule book…
“No player, substitute, coach or other person subject to the rules shall use
abusive, threatening or obscene language or gestures, or engage in such acts that provoke ill will or are demeaning to an opponent, to game officials or to the image of the game, including but not limited to:
(f) A player removing his helmet after the ball is dead and before he is in the team area (Exceptions: Team, media or injury timeouts; equipment adjustment; through play; between periods; and during a measurement for a first down).”
The crew has no choice but to penalize that action. The fact that he was out of bounds doesn’t matter because he wasn’t in his team’s box.
NFHS does not have a specific rule making that action a foul. It would be a judgment call as to whether or not the crew rules the action as unsportsmanlike.