I’m assuming you’re trying to be decent and want actual advice, not judging comments saying “self control”.
If it’s one person you’re afraid of cheating with because of a strong attraction or something, try to cut them out of your life. It’s hard, but you clearly care about your partner.
If you have issues with monogamy in general, try therapy. Maybe clue your partner in, tho I would discuss that with the therapist beforehand. It’s hard to control thoughts, so there’s no shame in needing help