Middle English dampnen, also damnen, dammen, late 13c. as a legal term, "to condemn, declare guilty, convict;" c. 1300 in the theological sense of "doom to punishment in a future state," from Old French damner "damn, condemn; convict, blame; injure," derivative of Latin damnare "to adjudge guilty; to doom; to condemn, blame, reject," from noun damnum "damage, hurt, harm; loss, injury; a fine, penalty," from Proto-Italic *dapno-, possibly from an ancient religious term from PIE *dap- "to apportion in exchange" [Watkins] or *dhp-no- "expense, investment" [de Vaan]. The -p- in the English word disappeared 16c.
The legal meaning "pronounce judgment upon" evolved in the Latin word. The optative expletive use likely is as old as the theological sense. Damn and its derivatives generally were avoided in print from 18c. to 1930s (the famous line in the film version of "Gone with the Wind" was a breakthrough and required much effort by the studio). Meaning "judge or pronounce (a work) to be bad by public expression" is from 1650s; to damn with faint praise is from Pope.
The noun is recorded from 1610s, "utterance of the word 'damn.'" To be not worth a damn is from 1817. To not give (or care) a damn is by 1760. The adjective is 1775, short for damned; Damn Yankee, the characteristic Southern U.S. term for "Northerner," is attested by 1812 (as damned). Related: Damning.