That intense pain you sometimes get when you eat ice cream too fast is technically called sphenopalatine ganglioneuralgia, and it’s related to migraine headaches
The pain of a brain freeze, also know as an ice cream headache, comes from your body’s natural reaction to cold. When your body senses cold, it wants to conserve heat. One of the steps it takes to accomplish this is constricting the blood vessels near your skin. With less blood flowing near your skin, less heat is carried away from your core, keeping you warm.
The same thing happens when something really cold hits the back of your mouth. The blood vessels in your palate constrict rapidly. When the cold goes away (because you swallowed the ice cream or cold beverage), they rapidly dilate back to their normal state.
This is harmless, but a major facial nerve called the trigeminal lies close to your palate and this nerve interprets the constriction/dilation process as pain. The location of the trigeminal nerve can cause the pain to seem like its coming from your forehead. Doctors believe this same misinterpretation of blood vessel constriction/dilation is the cause of the intense pain of a migraine headache.