Pain is something that in Polish usually kinda 'happens to you'. Your ear hurts to you. Your stomach hurts to you. I think a construction "jej ucho boli" (her ear hurts) is also possible but less common. I am a lot more likely to say "Boli mnie głowa" than "Moja głowa boli".
So in this more common option that is used here, the pronoun is in Accusative. Boli kogo? co? Głowa boli Jacka. Brzuch boli kota. (this is of course weird word order, because it's 'whom does the head hurt'?, but I'm just trying to explain the 'why'.)