If you're even considering cheating on your wife then maybe your marriage isn't worth continuing with and you should both go separate ways.
This is unfair. It's human and natural to look, and it's unnatural
not to look. He specifically said the thought was in the back of his mind, not the front. His penis may be up and looking for fun, but his brain is big enough to shout it down. He's not actually considering cheating, he's just saying that the situations occasionally present themselves.
As for me, there's only ever been one occasion when the opposite sex was hitting on me so hard that I couldn't ignore it, and I had to tell her, "Look, I'm going to have to ask you to stop, because I stick to my own kind." She took it well enough.
When I was young and geeky, people never hit on me, except for one time when I first went away to university. A guy asked me out, and I was so astonished by the entire concept of somebody being interested in me that I said yes, even though I wasn't interested in him at all.
When I was in my 20s and hot, I got hit on constantly - but then I constantly put myself in very sexual situations. I usually went for it. You're only young and hot for a short time, so make the most of it.
With my husband of 15 years, we had an open relationship, where we would pick up guys at bars for threesomes, go to bathhouses together, cruise the internet, etc. Don't try to tell me this means my relationship is worthless - it's all about the conscious and open decisions you make as a couple. We both accepted the fact that it was unrealistic to ever expect the other to never look at another man, and as long as we were safe and discreet, and the other was only ever another body in the bed and not another person in the relationship, then sleeping with other guys was fine. That's the benefit of being a same-sex couple rather an opposite-sex couple: Not only do your double your wardrobe, but you're both interested in the same kind of people - men.
Now that I'm older and fatter, the above principle in still officially in effect, but practically it's too much effort. Neither of us really get hit on or can really be bothered hitting on anybody else, so the issue never arises.