Fundamentally, if you are sticking your penis in someone's ass, you are basically signing a contract that says, "I am ok with having this person's shit on my dick." Or I guess more accurately, on the condom that is on my dick. (Right? Safety first!) I mean what else do you expect?
Still, though, I understand your concern. Nothing ruins the mood like shitting the bed, unless you're into that, I guess, in which case problem solved? But the likelihood of you actually doing a number two is pretty small. It just feels like you're going to, because there is a dick in the place where poop would be if it were ready to come out. If you look at a picture of the human colon (Wikipedia!), you'll see that there's a sharp bend between your rectum (where the dick goes) and the sigmoid colon (where poop is stored before you're ready to evacuate it).
Poop doesn't really hang out in your rectum, it is stored in the sigmoid colon until you're ready to shit it out, and then moves into the rectum, which is what makes that feeling like you've got to go. There's no way someone's dick is going to get around that sharp turn into the sigmoid colon, so really the only poop you have to worry about is whatever is stuck in your rectum.
So! Go to the bathroom before you get busy and try really hard to poop. Clean really well, or even shower if you want. Wash with soap. Some people like to do an enema before, and that's fine. You can buy those enema kits at the drug store, either the bag or a reusable bulb. It's probably best to just use warm water instead of the chemicals that come with the bag, because if you do it a lot you can start to mess up your intestinal flora, which can be bad for your digestion in the long run.
But really? You don't have to do that. Nothing against enemas and please do it if it makes you feel better, but the odds of you actually squeezing one out following anal are very small, especially if you tried your best to go beforehand. As any experienced ass fucker will tell you, it's best practice to keep a towel or baby wipes by wherever you're fucking just in case and to clean off the inevitable gunk. Gunk is just part of sex, and anyone who has sex is going to have to learn to live with a certain amount of gunk. That's life! Filled with sex gunk!
Given all that, though, to address your actual question: how does one stop feeling like one is going to take a shit all over sexy times? It just takes practice. Eventually, your anal sphincter/brain connection will figure out what's going on down there and stop sending those urgent "bathroom! bathroom!" messages. Knowing you aren't going to really shit probably helps too. As in all things anal, relax, practice, and you'll get more used to the whole thing.