Sugars in the Cough Syrup
There are ingredients in cough syrup such as high fructose syrup and sucrose. This is mainly done in order to mask the taste of the medications. If sugar was not added to the medicine then the medicine would taste bad and no one would want to purchase it.
However traces of these sugars are left behind in your mouth when you swallow it. These sugars can invite bacteria to feed in your mouth. Not only this, but once the sugars are broken down they can attack your enamel as well, making you more susceptible to cavities.
Acidity Levels
Along with sugars, there are also acids in the cough syrup, such as citric acid. Also, some syrups that have antihistamines in them have low pH levels with high acidity. These are a bad combination for your teeth, because they can also wear down the enamel. The more worn down your enamel is, the more susceptible you are to getting cavities.