I know the story in Genesis 38:8-10 is not talking about masturbation. I know some people call masturbation Onanism, even though the scripture is clearly not talking about this. However, could this scripture be used to forbid the use of condoms and contraceptives? Is continuing the family line not a moral obligation as it was at this time?
As I am sure you know, one can use the Bible to teach almost anything one wants if we are willing to do eisegesis (reading meaning into rather than out of the text). To use this passage as evidence that masturbation is sinful or as evidence (as Catholics do) that contraception is a sin, is to use the passage completely out of its context. In the context, the sin of Onan is selfishness. The tradition of his culture and, arguably, the biblical requirement as well, was for him to give the wife of his brother children so that her family line could continue. Onan wanted to have sex, but he did not want a child through this woman. Clearly, this was not something agreed to by the woman. This may have been for financial reasons, or perhaps there was something personal going on that we are not aware of. Therefore, he used her as a sex object, but did not love her, or obey God. Because of Onan’s selfishness, presumably, this woman was left childless, which was just about the worst tragedy for a woman in the ancient world. His sin was selfishness and lack of obedience to God, not masturbation (which he did not even do!) or use of birth control (which he did, but this passage does not address that issue).
Whether or not various modes of contraception, including the “rhythm” method or condoms or the IUD or even the morning after pill are immoral and sinful is something that Christians will debate, but the fact is that contraception is not addressed in the Bible. This is principally because none of the methods used today even existed in ancient times. Therefore, there was no reason for God to address the question.
I do not believe that continuing a family line is an imperative in the New Testament age. I see no evidence that any Christian is under the obligation of Onan to the wife of his deceased brother. This was a cultural thing from ancient times. For them, widows were not marriable, but for us they are.