Oh no, hopefully he will feel better soon. This sounds a little like my yorkie Pete, he has a collapsing trachea that we started noticing when he was around 6 months old. It kind of sounds like a long time smoker cough that turns into a gag. Pete usually only does this after he has been playing really hard and sprinting around, then we calmly settle him down so the episode can pass. I have heard of some dogs showing symptoms like this after surgery but Im not sure if it will go away on its own.
Im not too familiar with other things such as kennel cough and other respiratory problems so I could be completely off.