My puppy is 9 years old and when he drinks water he coughs a lot
Cough and sputum are very nonspecific symptoms.
To be able to confirm whether your dog have a respiratory tract or a digestive problem, you should take him to the veterinarian for a general examination and thoracic auscultation.
After it, your veterinarian will be able to assess if your dog has any problems and, if necessary, prescribe him the most appropriate treatment.
All the best.