If you do not have a history of severe headaches, then the answer is a definite YES. A sudden headache frequently indicates a severe, possibly life-threatening problem.
If you have severe headaches in the past, then the answer is more difficult. Many people who have headaches such as migraine and cluster headache can easily recognize their headache. If you have the same type of headache that you usually have, then it is probably safe not to go to the hospital. If your headache persists, you can go to the hospital. There are some medications for migraine that can be given only through the blood. You can get these in most hospitals.
Some medications for severe migraine attacks can only be given in a hospital.
If your headache is much more severe than usual, or if the headache is just “different” as compared to your usual headaches, then YES, you should go to a hospital. Having Migraine does not protect you from other serious diseases that can cause headaches such as infections and stroke.