The pain was not caused by the dream, but by a pain that existed in your head before the dream actually happened. It's fairly common, just recently I had a dream I was falling out of a canoe, and woke up falling off the bed. Dreaming occurs very fast, as you can experience quite a large dream in a small amount of time. In that fraction of a second it took me to fall off the bed, my dream was able to form some story of me getting in a canoe and falling out. Pretty trippy stuff. Anyway, if this pain keeps happening, you might need to see a doctor, though it's probably nothing.