We're all humans and we all have our flaws, I know I don't have a magic answer, and I believe Ava Marie raised several great points...
But don't be too hard on yourself.
Sometimes in retrospect we become aware of behaviours that we may regret, but no one on this planet has a time-machine.
There's an old proverb I'd like to share:
A father and his son were walking through town one day when they saw 2 men at the side of a home climbing a ladder.
The father asked his son, "Who is higher on the ladder?"
The son glanced over, and one man was on the 11th rung, the other was on the 5th.
The son exclaimed, "Well, clearly the man on the 11th rung is higher on the ladder!"
The father retorted, "Look again, what directions are the men going?"
The son looked and saw that the man who was on the 11th rung was going down the ladder, whereas the man on the 5th rung was going up.
Moral of the story: It doesn't matter where we find ourselves on the ladder of a life, but rather the direction in which we are going. Clearly you have recognized a pattern of your behaviour that is causing you grief, and while you can't go back in time to alter history - you can proceed forward in a more dignified manner!
Hope this gives you food for thought, and just go easy on yourself. Sex is a very fundamental need for most people.