pain (n.)
late 13c., "punishment," especially for a crime; also "condition one feels when hurt, opposite of pleasure," from Old French peine "difficulty, woe, suffering, punishment, Hell's torments" (11c.), from Latin poena "punishment, penalty, retribution, indemnification" (in Late Latin also "torment, hardship, suffering"), from Greek poine "retribution, penalty, quit-money for spilled blood," from PIE *kwei- "to pay, atone, compensate" (see penal). The earliest sense in English survives in phrase on pain of death.

Phrase to give (someone) a pain "be annoying and irritating" is from 1908; localized as pain in the neck (1924) and pain in the ass (1934), though this last might have gone long unrecorded and be the original sense and the others euphemisms. Pains "great care taken (for some purpose)" is first recorded 1520s (in the singular in this sense, it is attested from c.1300). First record of pain-killer is from 1853.
pain (v.)
c.1300, "to exert or strain oneself, strive; endeavor," from Old French pener (v.) "to hurt, cause pain," from peine, and from Middle English peine (n.); see pain (n.). Transitive meaning "cause pain; inflict pain" is from late 14c. That of "to cause sorrow, grief, or unhappiness" also is from late 14c. Related: Pained; paining.