Sadomasochism (abbreviated SM, S/M or S&M) is one aspect of what is today known as BDSM. It is a portmanteau of sadism and masochism and conveys the idea that sadism and masochism should not be seen as two distinct phenomena; instead, they are to be seen as one phenomenon that manifests itself in two inseparable aspects, the active (giving) and the passive (receiving) part.
This school of thought gained popularity and the concept was further expanded to the term BDSM which also includes bondage, discipline, dominance and submission, which are related to, but not identical with sadomasochism.
Sadomasochism, essentially, is about (sexual) pleasure derived from the infliction of pain. Typical activities to this end are whipping and other methods such as the use of clamps, needles, electrostimulation, hot wax, and many more.
Sadomasochism is also one aspect of spankophilia, but far from the only one.