"Ice cream headaches are caused by cold material moving across the roof of your mouth and the back of your throat, as happens when you eat ice cream quickly or gulp a cold drink. This may temporarily alter blood flow in your brain, causing a brief headache. Some researchers suspect that the pain is referred from the palate or teeth along the trigeminal nerve, which delivers sensory information from the face, teeth and tongue to the brain."
From what I've read on this the arteries in you neck start to spasm and allow too much blood flow to the brain causing pressure and pain. The reason that pressing your tongue tight to the roof of your mouth works is because the neck area tenses up, stopping the spasm and reducing the blood flow which relieves the former pressure.