Some say that in order for you to forgive someone, they have to come to you and ask for forgiveness. But if they don't come to you, you pray on the situation that God's will be done. That way, you can keep an open heart. And some say that even if they don't come to you, forgive them in your heart. I don't have a sure answer, but both seem pretty good to me. Perhaps a fellow brother or sister can help me out with biblical reference.
As for the part in the Bible where Onan spilled his seed, many argue that God killed him because he did not preserve seed for his brother. I suppose this was dishonorable to God, for Onan to get rid of his brother's name and also hindering the promise of Abraham to multiply his seed. Also, Onan was from the tribe of Judah, which the Messiah was to come from. As for today, the act of masterbation is usually associated with sin because it involves lusting in your thoughts, which Christ condemns and considers committing adultery in your heart [Matthew 5:28]. One can masterbate without sinful thoughts, which for the most part, does not happen. You can do a search on this forum, there's many topics on that matter.