That, I do believe, is one of those classic questions that couples have been trying to answer for as long as the concept of a "couple" has even existed, and the truth is that the answer probably depends on the couple.
What I would say is this
1) As a general rule, a significant other probably shouldn't be spending too much time with their ex. I realize that this can suck, my best friend is my ex, and one of the things that scares me off from trying to start new relationships is that I'm really afraid of how I'm going to have to answer that question. I want to find love, but I don't want to give up my best friend. Like most things, there are no easy answers here, but if I ever do find the right relationship I will, at the very least, have to significantly cut the amount of time I spend with my friend. Moral issues aside, an ex always stirs up emotions on both sides of the relationship, and if you want to have a well functioning relationship you will probably have to make a choice.
2) If your significant other is hanging out with an ex, it's probably best for you not to make a big deal of it. As I've already mentioned, this is one of those really difficult questions that every couple has the answer, and what makes it so difficult is that the party in question is forced to choose between someone from their past in whom they may have had a sizable emotional investment, and someone from their present in whom they currently have an emotional investment. Asking someone to tell someone they may care about to not see them anymore is a really big thing to ask. If you want it's certainly an option to create an ultimatum, though I would say that in regards to just about any question a relationship faces issuing an ultimatum can often backfire, and it's certainly not a healthy way to address problems. Probably a better option would be to talk to your partner and tell them how you feel when they hang out with their ex. A stable relationship, after all, is built on communication. This could certainly still cause problems, and if you choose to talk about it you have to make sure that you listen to your partner's feelings. As I've already said, asking someone to break off a friendship is a really big thing to ask them to give up, and if you're going to ask for it, the least you could do is be understanding with them.
3) The best option, if you want to make sure that your partner's chats with their ex don't turn into something more, is to simply be caring and understanding. Changing your own behavior is a much better option than trying to force your partner to change theirs. If you treat your partner well, and you have a stable and trusting relationship, they you shouldn't have to worry even when they do hang with an ex. Infidelity is uncommon in happy couples, and if it does occur in a stable relationship it is probably more than enough grounds to take a second look at the relationship and consider if your partner is right for you to start with. So the best step you can take if your partner is chatting with an ex, and it's troubling you, is probably to just treat them well (don't go over the top of course, if they realize that you're acting weird that can create problems as well). If you treat your partner right (assuming they aren't a sociopath) then they're not likely to cheat on you, and they may even realize on their own that hanging out with their ex isn't appropriate and break it off without you even having to ask.