"The sin of Onanism", as the Catholic churches like to call masturbation, came from the old testament story of a widow in need of a "protector." After a girl's husband died it was the duty of her brother-in-law to marry her, to make sure she still had a secure place in the family group. And marriage then was not about a ritual celebration, it was about the guy having sex with her, and preferably getting her pregnant. That is why the old testament has recitations of who "knew" (fucked) who, that was marriage back then.
As Genesis 38 tells it, Er, Judah's firstborn, erred in the god's sight; so naturally god wasted him.
Anyway, dad strides up to Onan, reminds him it's his duty to keep Tamar preggers now, and shoves him through the girl's doorway. Well, Onan knows that his father's inheritance will be split amongst any children he makes with Tamar, and is not so keen to make rivals for Daddy's wealth. But not one to miss out on a fuck, he starts out ok, then whips it out at the last minute, "spilling his seed on the ground," so god offs him as well.
And the screwed up church never says a word about coitus interuptus, just tells us god won't approve if we touch ourselves.
I wonder how many marriages have been screwed up by boys being indoctrinated with the idea that they can only do it with a girl, and girls being indoctrinated with the idea that girls just don't like that sort of thing.
Btw, the rest of this story is a hilarious account of how this spunky woman got her own back, one no church will want you to read.
http://www.biblegateway.com/passage/?book_id=1&chapter=38&version=31&context=chapter