Depends... The best treatment depends on the etiology of the cough. Are you coughing at night when you lie down? If so, this could be due to post-nasal drip which has a very different treatment than bronchospasm (which is another possibility). Other etiologies include gerd which also worsens when lying down. All these possibilities have very different treatments. See your doctor for diagnosis and treatment.
Nighttime cough. If the cough is a back of the throat tickle due to mucous draining down from the nose and sinuses when you first lie down, i personally find the most effective medication to be a mixture of Phenergan (promethazine) and Codeine cough syrup. If the nighttime cough is happening in the middle of the night associated with a sensation of tightness or wheezing in the chest, asthma inhalers will be more effective.