When a dog becomes excited, he breathes harder and quicker, which can irritate his respiratory system and thus cause him to cough. If you're noticing that he does it constantly or that the frequency increases, I would schedule an appointment with your vet. Oftentimes, a cough is a sign of a mild respiratory infection or something lodged in the pet's throat. If your dog has recently been in a kennel, at a dog park, or anywhere where many dogs are present, he could have Kennel cough, which is the most common cause of coughing in dogs. While the initial symptom may only be coughing, you will soon notice that your dog is becoming more tired/lethargic, has a fever, and has a clear nasal discharge. If the problem is more long-term and unaccompanied by other symptoms, you will still want to check with your veterinarian to rule out a bacterial infection in the lungs, nasal passages, or throat.
Coughing spasms can be brought on by excitement or exercise. Other conditions to be cautious of would include reverse sneezing, heart disease, chronic bronchitis, heartworm disease and some types of cancer . If the condition persists consult your vet .