Named after the Marquis de Sade, famed for his libertine writings depicting the pleasure of inflicting pain to others. The word for "sadism" (sadisme) is forged or acknowledged in the 1834 posthumous reprint of French lexicographer Boiste's Dictionnaire universel de la langue française; it is reused along with "sadist" (sadique) in 1862 by French critic Sainte-Beuve in his commentary of Flaubert's novel Salammbô; it is reused (possibly independently) in 1886 by Austrian psychiatrist Krafft-Ebing in Psychopathia Sexualis which popularized it; it is directly reused in 1905 by Freud in Three Essays on the Theory of Sexuality which definitely established the word.
Sadism refers to sexual or non-sexual gratification in the infliction of pain or humiliation upon another person. Masochism refers to sexual or non-sexual gratification from receiving the infliction of pain or humiliation.
Often interrelated, the practices are collectively known as sadomasochism as well as S&M or SM. These terms usually refer to consensual practices within the BDSM community.