To avoid throwing up when coughing too much drink plenty of water and stay hydrated.
Also try drinking some hot tea with honey as the hot tea and honey can soothe your throat and help stop the coughing.
Apply some Vicks VapoRub to your chest or nostrils to help you ease the coughing as well.
Try sucking on some cough drops and take some cough medicine.
Eating some raw ginger is also another way to help stop coughing and avoid throwing up.
Get rid of cough by eating raw Ginger.
Or Grind 50gms of ginger and mix with lime juice.
Add some pinch of turmeric and 10gms of pepper.
Add some salt.
Drink this mixture early morning in empty stomach and evening before sleep.
It has good results. I personally tried this. It keeps your lungs free from infection.
You can drink this juice on a daily basis as well.
Vomiting or throwing up or gagging when coughing is normal and nothing to worry about although it can be unpleasant.
The best way to completely stop the vomiting when coughing too much is to stop the coughing or slow the coughing.