What sounds like an "inside out sneeze" and frequently referred to as reverse sneezing is actually a spasm that results from an irritation to the soft palate - the area in the upper back of a dog's mouth.
Sometimes it's triggered by activity or tugging on a leash/collar, even after eating or drinking. If it's something that happens frequently, the dog needs to be evaluated for polyps or infection. It's a pretty regular reaction to pollens or other airborne irritants. There is also a possibility of nasal mites - and you certainly want to address this as soon as possible. For the most part though there's no identifiable cause.
By scratching this sort of ‘itch' for your dog, you may end the spasm. If it's safe, rub the back of your dog's throat - or touch as far back on their tongue as you can (again, safely).
Encourage a good swallowing motion by offering a cracker with peanut butter on it.
If this is actually a dry, hacking cough that sounds like something might be stuck in the dog's throat, it's probably Kennel Cough. Sometimes this cough is so hard that the dog will bring up white phlegm; also, coming in from outdoors (changes in environmental temps) may trigger a coughing outburst.
Kennel Cough (Bordetella Bronchiseptica) has an incubation period of 2 to 14 days. It's often caught while dogs are boarded in kennels (hence the name) or even in dog obedience classes, dog parks, vet waiting rooms, etc..
Bordetella B. is an airborne infection that's transferred when dogs sneeze or cough and project droplets into the air in the vicinity of another animal. Direct contact between animals or sharing food/water bowls and in some cases when a dog comes upon an area that an infected dog recently visited may transfer the infection. This bacteria, in normal situations, isn't especially difficult to treat. There is usually a secondary infection (or more) that needs to be addressed in order to eliminate the problem, so a vet check is warranted. The treatment is an antibiotic medication that may be given with a cough suppressant (a med that is prescribed )
Other causes for dog coughing are environmental, like cigarette smoke exposure, dust, temperature extremes (too hot, too cold) and even stress. It could be tracheal disease or just allergies.
Setting up a vaporizer (without medications in it) in the room with the dog may also prove helpful. Offering a heat source such as a heating pad set on low, beneath their bedding may make them more comfortable too; however, I prefer to avoid electric sources an animal may gnaw on. We use rice socks. Fill any clean sock ¾ of the way with uncooked rice and knot the end closed. Microwave this for 1 to 1 ½ minutes, shake it out to distribute the heat and make sure it's not too hot - tuck it in the dog's bedding - it stays warm and holds body heat for hours. It's very important to remember that these are just temporary, possible relief's - in no way a cure. These will not make the animal ‘better'.
For more dog-cough information: http://www.canismajor.com/dog/cough.html