Why can ice cream give you brain freeze?

The change in temperature of the roof of your mouth is what causes a brain freeze. If you rub your tongue on the roof of your mouth, it will go away more quickly.