The general rule in the military is that dating or having a relationship with a subordinate is prohibited. There are, however, some exceptions to the rule.
There are several articles in the Uniform Code of Military Justice (UCMJ) that address and define fraternization of military members. Each branch of the military also has its own rules and regulations on fraternization and unprofessional relationships. However, the general rules are the same from branch to branch.
Officers may have relationships with each other outside the workplace, so long as the two officers do not work together in the same shop or office. The officers must also not be in each other's chain of command.
Officer and enlisted
Officers and enlisted members are generally prohibited from having relationships outside the workplace. However, punishment is at the local commander's discretion, and the general rule of thumb is that if the two members are not in each other's chain of command, and the relationship is not detrimental to good order and discipline, then the unit will allow the two members to carry on a discreet relationship.
Enlisted members may have relationships with each other outside the workplace, so long as the two enlisted members do not work together in the same shop or office. The enlisted members must also not be in each other's chain of command.