Genesis 38:9
New International Version (NIV1984)
9 But Onan knew that the offspring would not be his; so whenever he lay with his brother’s wife, he spilled his semen on the ground to keep from producing offspring for his brother.
From BibleGateway.com: http://www.biblegateway.com/passage/?search=Genesis 38:9&version=NIV1984