I believe it's needed because this is in the present continuous, i.e. it "is hurting" (as opposed to "hurts"). So, I believe if you left out the हो रहा it would mean "my head hurts."
The हो specifically is the root of होना, "to be," which is then paired with रहा to make the present continuous.
I wrote "I am having headache" - the Hindi sentence is clear, of course, but my translation apparently bad (no native speaker). Normally, I would simply say "I have headache", but the Hindi sentence obviously requires a translation as a progressive tense.