A dry, hacking cough that sounds like something might be stuck in the dog's throat is one of the symptoms of 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.. It's more commonly passed along in poorly ventilated areas (and puppies in pet stores or shelters are especially vulnerable). It's a bacteria which 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).
In dogs with immune system or other problems, this could be a more serious condition and indicate emergency treatment to insure a better chance of survival.
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.
Heartworm may cause coughing, shortness of breath and other signs of distress.
To make him more comfortable until you see the vet: Some people recommend Robitussin DM .5 to 1 mg per pound. There are eye dropper/measuring delivery systems available for baby care in most pharmacy aisles of stores. They're great to have on hand for pets.
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 reliefs - in no way a cure. These will not make the animal ‘better'.
For more dog-cough information: http://www.canismajor.com/dog/cough.html