Yes..he pulled out and spilled his seed against Leviticus law
But I see no bearing on using a condom...
A condom is a barrier...
Well, Onan is in Genesis 38, so he predates Levirite law, although he does presage it. He did not use a condom because no one yet had invented them. Instead, he practiced the primitive form of birth control most readily available to him. Rather than declining to contribute as biological father of the children of Tamar altogether, he went halfway, beginning the act but intentionally stopping short of accomplishing its procreative aim. A condom merely provides a more technologically sophisticated method of doing likewise.