Short answer
Drinking something icy or eating cold foods like ice cream too quickly can trigger what's known as a 'brain freeze.' While the exact cause of this brief but sharp headache isn't entirely clear, one theory suggests it's linked to the activation of the 'trigeminal nerve' in your palate due to the cold. This activation prompts the blood vessels supplying the brain to widen, increasing blood flow to help prevent the brain from cooling down excessively. However, this sudden change in blood flow can raise the pressure in your head, potentially causing the discomfort associated with brain freeze.
Longer answer
Want to read more about brain freeze? Marlijn ter Bekke has written a fascinating article on the subject for Donders Wonders – click here!