It was physically impossible to be offside, even if he went past the last defender he was never ahead of the ball at any time.
He did exactly the right thing, the angle of the header made it entirely possible it might bounce back off the inside of the post & he'd then be rightly lambasted for...