It's hard when you're with other kids whose parents allow it. When potty talk happens here, I give them a bit of leeway, a few reminders, but if it continues, I ask them to remove themselves to the bathroom, since that's where bathroom talk goes.
A lot of times with boys my oldest's age (6), I find that a lighthearted approach works well, if you are in charge of a playdate or something. "Hey guys! If you keep up the potty talk, you have to go where the potty is!" and another, firmer warning, "I'm serious about it, in our house we talk about bathroom stuff IN the bathroom." with a smile but a firm look, IYKWIM. Then off to the bathroom, and they get bored RULL fast.
If we're in public, I pull him aside and remind him and give him leeway for being excited and getting carried away, but still expect him to try his best to remember.
Mama to H (6) B (3) : A (1)