Before we start, let's get one thing out of the way: there are a lot of reasons why people cheat, and some of them cannot be controlled by you or your actions. Some people will cheat because they find the idea sexy. Some will cheat because they feel uncomfortable in a monogamous relationship. We are going to assume that you are not currently in a relationship with someone like one of these people (or if you are with the latter, then that you're comfortable with consentual non-monogamy), because if you are, then there is likely nothing you can do that will prevent a partner cheating on you.
So let's say you're in a relationship with someone you've vetted well, and who you don't think is going to cheat on you, at least 97% of the time. Well, what do you do when jealousy starts creeping in? When you see him talking to his cute coworker, when you notice his ex from 10 years ago liking his pictures on facebook, when you realize he's texting a female friend about something or other?
I'm going to bet that the majority of the time, your first instinct, after that initial punch of jealousy, is to draw away, to secretly "punish" him for this as a means of gaining power over your insecurity. More likely than not, you're going to want to shit-test him, maybe stop talking as much, sulk, pout, become cold, or any other number of negative things. I'm not judging, most of us have been there before. But the thing to remember is that the more you act cold or try to punish him for a percieved misstep, the more you will push him away, and the more you could end up leading him exactly where your jealous insecurity initially imagined things going.
Now let me be clear -- if you genuinely suspect that your partner is cheating on you, that's a completely different story, and calls for a completely different set of guidelines. But if all you're dealing with is, essentially, a hamster run wild with baseless fears, then what follows is meant for you.
So here you are, walking out of a store with your boyfriend where he ran into an ex and gave her a hug. Uh-oh! You're feeling jealous and possessive. What do you do about it? Do you give into your first instinct, give him the cold shoulder on the ride home, and sulk all through dinner? If your answer is "yes" ... girl you have a lot of work to do.
What to do when you feel jealous:
The number one thing to do is to neutralize the initial feeling. This is the one that is definitely the hardest to do. But try to think about the good things the two of you have together, the fact that he picked you and not this other person, and other such things. Redirect your mind into something else, and especially something positive. If you didn't catch yourself quickly enough and realize that you were acting rudely, apologise. There is no shame in saying, "I'm sorry I was being cold, I felt a little jealous when I saw Whatshername." And then, after you've done that, go back to your normal self, and do not make it a habit of acting poorly then apologising afterwards. If you do, then your apologies will eventually become meaningless.
So you've successfully escaped the difficult Ex At The Store scenario. Now what? What happens every other time you run into a situation that brings your insecurity to the forefront? Neutralizing the initial feeling is great, but it isn't a longterm solution.
The longterm solution is to work on yourself. If you love yourself, if you realize the amount of worth you bring to a relationship, and if you're comfortable -- absolutely and completely -- with yourself, then you will find your insecurity and jealousy will not come up as often. Always ensure that you are a well-rounded person. This means that you should not only work on improving one aspect of yourself, but all of them. Do you have a great ass from all the squats you do? That's awesome! But a great ass doesn't make a great person. Always strive to improve yourself intellectually, physically, and creatively -- this means you should try to have one hobby that fits into each category: read books, work out, play music; learn a language, kickbox, paint ... the possibilities are endless. All too often, people think that because they're quite successful in one or two of these areas, that they can neglect the other(s). This isn't the case. Self-improvement is the one place where you should never neglect things. And the more you work on yourself, the comfortable and confident you will be -- meaning fewer "maybe Marcia in Marketing is going to steal my man", because if you bring everything he wants to the table, he may look, but a good man isn't going to touch.
Last but not least:
When you're feeling jealous, be better.
"I was planning on baking my boyfriend a cake, but I saw him looking at Cashier Carol's butt, so now I'm not going to!"
NO, stop this. If you start feeling your jealousy and insecurity coming in, use it as an opportunity to treat your partner. Do something extra nice for him, make him feel even more loved and appreciated than usual. He will notice. Why would you want to do this? Because the more you give to him, the more he will want to give to you. Because by withdrawing affection, you will cause him to seek it elsewhere. Will this happen right away? No, probably not. But it will eventually, and then the only person you'll have to blame for him running to Painter Patricia is yourself.
tl;dr don't punish your partner for something he didn't do; work on yourself; kill your jealousy with acts of kindness and love.