The Bible says God will forgive all your sins if you ask Him with a sincere and repentant heart. Many times people will make the decision to go ahead and sin, or in this case, to go ahead and have sex outside of marriage, since God will forgive them later. These people forget that God looks at the sincerity of a person's heart when He grants forgiveness. He does not forgive just because a person says the words "forgive me." The Bible says that before you seek forgiveness, you must first repent. To repent means to turn away from your sin and move in the opposite direction.
God's gracious gift of forgiveness cannot be used as a license to do whatever you want with the thought that He'll clean you up in the end.
Dick Purnell says, "Forgiveness and the power to change are two sides of the exact same coin. When God works in your life, change is what He wants to see—change for the good and for the better, not just, 'Oh well, He'll forgive me.'"
You cannot try to manipulate God's character—expecting Him to forgive when you want to be forgiven, to bring about a change when you want a change, or to answer a prayer a certain way because you feel that's the best answer.
"Repent, then, and turn to God, so that your sins may be wiped out, that times of refreshing may come from the Lord" (Acts 3:19).