Most Helpful Girl
I think it has a lot to do with where exactly your extreme desire to have sex comes from. Is it genuine sex drive? Do you do this to make your self-worth feel more whole? Is sexual abuse a factor? Are you at a loss for how to solidify a connection without having sex? Do you feel like your central charm and magnetism lies in what you present sexually? You need to take an honest, unfiltered look at yourself and why this habit exists. Once you pinpoint the precise reasoning behind this habit, then you can dismantle it.
What it really comes down to is self-control, self-discipline, and making the choice that's going to be the best absolute service for your future self on all levels. Not just the choice that satisfies you in the moment, but a decision that pleases you mentally, emotionally, spiritually, and physically long-term. Even if you have to physically get up and remove yourself from a situation then do so.
You're already off to a great start humbly recognizing that this habit is not putting you in the direction you want to be in! So give yourself a pat on the back for even recognizing that this is a problem in your life which needs to be addressed.