The theological term for the crime committed by married persons, who in the performance of the conjugal act aim to prevent conception.
The name is derived from Onan, the son of the Patriarch Juda, mentioned in the book of Genesis (38:8).
When Juda requested Onan to marry his (Onan's) brother's widow, in order to raise up progeny to his brother, Onan frustrated conception.
"And the Lord slew him, because he did a detestable thing."
The more popular terms for onanism are: birth control, family limitation, race suicide, and neo-Malthusianism.
Onanism is always a grave sin.
It is a crime opposed to natural law, for it frustrates the primary purpose of matrimony, namely, the procreation of offspring.
In extreme cases, for example, when there is danger to health or life to one or both parties, married persons should simply abstain from the conjugal act.
New Catholic Dictionary