late 14c., "that which is censurable, wrong-doing, an offense, a crime," from Old French desmerite "blame, demerit" (Modern French démérite), from des- "not, opposite" (see dis-) + merite "merit" (see merit (n.)) or from Latin demeritum "fault," from past-participle stem of demereri "to merit, deserve," from de- in its completive sense.
Both senses, "that which one deserves," whether good or bad, existed in the Middle French and Middle English words. The positive sense in English faded mid-17c. Meaning "penalty point in school" is by 1862, short for demerit mark.