It will depend on the overall circumstances.
There could be no punishment all the way up to a court-martial and discharge
from the military.
The military has usually taken more of a hands-off approach in the last 10 years or so.
Here are the factors they look at.
Article 92, UCMJ, for violating the fraternization regulations if another servicemember is involved.
Article 134, UCMJ, for adultery. While adulterous conduct that is private and discreet in nature may not be service discrediting by this standard, under the circumstances, it may be determined to be conduct prejudicial to good order and discipline. Commanders should consider all relevant circumstances, including but not limited to the following factors, when determining whether adulterous acts are prejudicial to good order and discipline or are of a nature to bring discredit upon the armed forces:
(a) The accused’s marital status, military rank, grade, or position;
(b) The co-actor’s marital status, military rank, grade, and position, or relationship to the armed forces;
(c) The military status of the accused’s spouse or the spouse of co-actor, or their relationship to the armed forces;
(d) The impact, if any, of the adulterous relationship on the ability of the accused, the co-actor, or the spouse of either to perform their duties in support of the armed forces;
(e) The misuse, if any, of government time and resources to facilitate the commission of the conduct;
(f) Whether the conduct persisted despite counseling or orders to desist; the flagrancy of the conduct, such as whether any notoriety ensued; and whether the adulterous act was accompanied by other violations of the UCMJ;
(g) The negative impact of the conduct on the units or organizations of the accused, the co-actor or the spouse of either of them, such as a detrimental effect on unit or organization morale, teamwork, and efficiency;
(h) Whether the accused or co-actor was legally separated; and
(i) Whether the adulterous misconduct involves an ongoing or recent relationship or is remote in time.
Depending on how seriously the unit treats the case they could take one of several actions.
A verbal or written counseling not to do it again.
An Article 15. Follow a link for a range of punishment.
A court-martial IF the case is considered flagrant and aggravated by the circumstances. At a SPCM the potential maximum could include reduction to E-1, forfeiture of up to two-thirds pay per month for up to 12 months, confinement for up to 12 months, and/or a bad conduct discharge.
What the command decides to do will depend on how serious the conduct is viewed, the parties attitudes, their reputations and prior service, etc.
Hope this helps.