Hello. Thanks for your question.
Coughing in dogs is often due to one of the following: kennel cough (infectious disease of the trachea/ windpipe), collapsing trachea, pneumonia, heart disease, cancer (primary or metastatic to lungs) or bronchitis.
The only way to know for sure, is to get some chest x-rays. During the exam, the vet will listen for a heart murmur and crackles or wheezes in the lungs. This would point to heart disease or bronchitis, respectively. Even when the lungs sound normal, we can still see pockets of pneumonia or lung tumors.
Just generally speaking, if the cough is more prominent when laying down or at night then it's more likely to be heart disease. If it's more prominent when excited, then collapsing trachea is more common. If it's productive and he brings up green or brown phlegm, then pneumonia is more likely. If it's wheezy, then bronchitis is more likely.
I hope this helps, let me know if you have any other questions.