Codeine is used to treat moderate pain and it is also a narcotic pain reliever that is used to treat pain, cough, and diarrhea. Codeine belongs to the opiate (narcotic) analgesics and antitussive classes of medications.