The main point in the Onan passage is he was failing to fulfill his responsibility of the Leverite marriage of raising up children for his brother who died. The sin wasn’t spilling the seed on the ground, but very specifically trying to not fulfill the command of God. I don’t think that in Gen. 38 there’s no significance to it related to contraception, but certainly that’s not the main concern of the passage.
In a marriage, is there ever a time where sex is desirable on the basis of something in addition to conception, having children? There’s no passage that says every physical act between husband and wife should result in conception, but there is a specific command in OT to raise up children for your brother who has died.
Having thought through this issue I understand both sides and if I had it to do over again I would not be as quick to recommend that people use contraceptives. I no longer assume it to be the best option, I think it should be weighed and measured. I’m not ready to say it’s wrong but I think clearly children are a blessing from the Lord. What other blessing do we ask God not to give us?