Too much water in the blood, detected by the hypothalamus. Less ADH produced by the pituitary gland. Blood becomes more concentrated. Blood returns to correct osmotic concentration. Beer contains alcohol which is a diuretic.
Tea also contains a diuretic.
Diuretics are the opposite of anti-diuretics. The alcohol in your beer makes you produce lots of urine and this results in your blood becoming very concentrated. The nasty feeling in your head is caused by the effect of the very concentrated blood on your brain cells. You can stop yourself from becoming too dehydrated by drinking lots of water. If you know that you have had too much beer, drink lots of water before you go to bed.