Augustine on Onan...
Genesis 38:8-10 Then Judah 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 semen on the ground, so as not to give offspring to his brother. And what he did was wicked in the sight of the Lord, and he put him to death also.
And why has Paul said: 'If he cannot control himself, let him marry?' Surely, to prevent incontinence from constraining him to adultery. If, then, he practices continence, neither let him marry nor beget children. However, if he does not control himself, let him enter into lawful wedlock, so that he may not beget children in disgrace or avoid having offspring by a more degraded form of intercourse. There are some lawfully wedded couples who resort to this last, for intercourse, even with one's lawfully wedded spouse, can take place in an unlawful and shameful manner, whenever the conception of offspring is avoided. Onan, the son of Judah, did this very thing, and the Lord slew him on that account. Therefore, the procreation of children is itself the primary, natural, legitimate purpose of marriage. Whence it follows that those who marry because of their inability to remain continent ought not to so temper their vice that they preclude the good of marriage, which is the procreation of children.
Augustine of Hippo, De adulterinis coniugiis ad Pollentium 1b.II c.12 (PL 40  479B). Quoted from Pius XI, Casti Connubii (1930)