"Don't S**t Where You Eat"
Solution 1:
I don’t know about the history of it, but yes, it often means “don’t have a romantic relationship in the workplace”.
Alternatives without shit:
“Don’t soil your own nest”—true to the original, and not crude.
“Don’t dip your pen in company ink”—this seems more male-focused.
“Don’t get your meat where you get your bread”—neutral, but still a little crude. It uses meat as a euphemism for sex/romance, and bread as an idiom for money.
“Don’t get your sugar and your bread at the same store”—neutral, and more innocent. Sugar is sometimes used as a euphemism for love, romance, or kisses.
Solution 2:
While "don't shit where you eat", and other variants of the idiom are often used to dissuade someone from "dipping their pen in the company ink", they are also generally used as a reminder simply to not foul up a place, or situation in which you frequently find yourself. For example; don't cause a ruckus at, or steal from the store you do all of your shopping at. Or, don't be an asshole to the barista at the coffee shop you get your low-fat, no foam, javamochacappuccino with soy at every morning. This idiom, and it's variants, are not limited solely to inter-work relationships. 1. I was born in 1987 and have heard this idiom throughout my life..mostly from people older than me. I am unsure when it became popular. 2. Use poop. Or poo. Or scat. Or dookie. Or dump. Or use the variant, "don't foul your own nest". Or just use shit..it really has a way of driving the point home. 3. She (Amy BBT) was being serious in the way she used the idiom, and the point she was trying to convey. But as I stated above, the idiom can be used in similar, but different situations..and not solely to advise against inter-work relationships.
Solution 3:
"Don't shit where you eat." I heard this advice from my mother, who was born in 1917, and who was otherwise very proper and ladylike in her language. My understanding has always been that it meant that you should not do anything (gossip, complain a lot, argue with the boss, have an affair) in your place of work, as it often comes to a bad end for you. In other words, you depend on the place for income (food); don't foul it up (shit). While the language is crude, it drives the point home and is memorable.
Solution 4:
I believe this is an abbreviated form of an old adage:
Even a dog knows not to defecate where he sleeps.
That's the way I first heard it back in the 80's. The awkward way I used to hear it quoted told me it was an oldish cliche at the time. When people change quotes, they tend to make them more direct and simple (rather than less). I never heard the simpler and/or "eats" variants until recently.
And yes, every time I've heard it in the wild, its been with the old English 4-letter-word, not with "defecate". IMHO if you are using it with any other word (like I did here), you are euphemizing it.
Note that while this behavior is normal for wolves, not all dogs are actually so great at it...