There is a misconception over the sin of Onan at Genesis 38:9.
People are unaware of what Onan was really doing wrong, so they misunderstand and think that it is a sin to waste a man's seed.
So from their misunderstanding, they may teach that it's sin to use what today is called "the pull out method" in your marriage.
There is not such a commandment in the bible, and people are getting this idea because they're not actually familiar enough with the bible, and fail to understand what is really going on.
There are entire congregations who work at spreading this misconception and teach this is a sin, it was probably made most popular by the Catholic congregation.
This misconception causes a number of other false teachings as well.
The misconception that it is a sin for a man to "waste his seed" comes from the scriptures at Genesis 38:9, where it says Onan kept pulling out and wasting his seed outside of Tamar, and it says what he was doing was wicked in the sight of YHWH, so YHWH put him to death.
So yes, if you want to be one of those people who are too lazy to read the word of YHWH and the bible, and just browse a few verses here and there and then claim to know what the bible says, then yes, it certainly is easy to misunderstand Genesis 38:9 and think it said pulling out is a sin, as well if you're just reading the bible for the 1st time and get to this part, you may jump to that conclusion.
YHWH gave his entire law to Yisrael through Moses, so if this was a sin, we would find it in the Law he revealed, but there is no command saying do not waste your seed.
However, we do find the actual sin that Onan was committing in the Law of YHWH;
Deuteronomy 25:5 "If brothers dwell together and one of them dies and has no son, the wife of the dead man shall not be married outside the family to a stranger, Her husband’s brother shall go in to her and take her as his wife and perform the duty of a husband’s brother to her, And the first son whom she bears shall succeed to the name of his dead brother, that his name may not be blotted out of Yisrael"
Onan's brother Er had died because he was evil in the sight of YHWH.
Since Er had died and had no son, and he did have a brother, it was one of his brothers duties to raise up a male child for the dead brother and the first born would belong to the dead brother.
Also Er's wife Tamar had the right to a brother, so once you know this commandment from YHWH, when you read Genesis 38:6 again you can understand it.
At Genesis 38:6 it even actually mentions "the duty of a brother in law" plainly, helping us know the context, though the word of YHWH is so foreign to modern Christians, they don't seem to think much of that duty, or link it to the wasting of the seed.
Read it again now;
Genesis 38:6 "And Yahuda took a wife for Er his firstborn, and her name was Tamar, but Er, Yahuda’s firstborn, was wicked in the sight of YHWH, and YHWH put him to death. Then Yahuda said to Onan, Go in to your brother’s wife and perform the duty of a brother-in-law to her and raise up offspring for your brother, but Onan knew that the offspring would not be his, So whenever he went in to his brother’s wife he would waste the seed on the ground so as not to give offspring to his brother, And what he did was wicked in the sight of YHWH and he put him to death also"