In this example you don't have to insert "an"... but you could. If you're talking about a specific pain. You can experience pain (general) or a pain (specific location or object). "That person is a pain in the rear." Or "He causes pain to others."
As to when you use "a" or "an", believe it or not, some native English speakers still don't master this. Especially in writing. But it's quite simple.
If the next word to follow that article SOUNDS like a vowel, a, e, i, o, or u, (not y) then you'd use "an". This creates a break between the words so that they don't run together. But remember that it just has to "sound" that way to apply. For example. If you say that someone is "an honest person" you would use "an" because the h in honest is silent and so the beginning of that word SOUNDS like a vowel. It's different from "a horse", in which you would push out air to make the h sound. I hope this is helpful. Take care.