I carpool with a male coworker, and he and I have become friends.

And you can indeed have a policy that requires one of the parties to move on if a relationship happens.
What’s not legal, though, is to always have women be the ones who have to leave.
Often, an employee will argue that he or she was an unwilling participant in a relationship that merely appeared to be consensual.
Even a consensual relationship, if it goes sour, can result in unwelcome advances, stalking, or other predatory conduct.
While it can make some managers uncomfortable to tell employees what to do on their off time, the purpose of a formal policy is to keep employees effective and productive.
Make sure employees understand the position of the company isn’t to control their personal lives, but to ensure a fair and comfortable work environment for everyone.
Workplace romances tend to be the stuff of legend – either because a department (or entire company) got dragged into the drama, or the couple lives happily ever after. For that reason, many companies discourage interoffice dating. Yes, it may feel weird to try and control someone’s love life, but your job as a leader is to ensure a fair and equitable workplace.
Lest you feel hard-hearted for discouraging workplace lovebirds, consider the turmoil and drop in productivity that can be caused by gossip, poor morale, and accusations of favoritism or sexual harassment charges.
Two of my coworkers have warned me to be careful, as there have just been rumors of people in the past possibly having relations and the woman was always the one to be terminated.
It is indeed legal to prohibit dating between coworkers (with a few exceptions, such as in California, where courts have ruled that the state constitution provides broader privacy protection in employment matters).
Chas Rampenthal is general counsel and vice president of product development at Legal Zoom.