Both the defender who tried the head the ball and the attacker who tried to kick it did not play/touch the ball.
Although the Law 11 and its Guidelines & Instruction don't say it explicitly, based on the FIFA
current interpretation " a player in an offside position who attempts to play the ball is considered to be interfering with play".
Therefore as the attacker was in an offside position and clearly attempted to play to ball, he shall
be penalized. Please notice that "clearly" means that the ball has to be really very close to the
player who attempts to play.