Not popular here but it's the correct call. At the moment of the header the offside player is standing directly in front of the goalkeeper, in his line of sight. That's an offside, because the moment of the header is what counts. You judge offside from the moment the pass is played to the goalscorer, not when the goalscorer then takes a shot.
You're working backwards to explain a mistake here.