While adultery is not a specific offense under the UCMJ, it is prosecuted under Article 134 (the general or "catch-all" article) for actions contrary to good order and discipline.
The President (Martin Sheen)'s cabinet resigns before the beginning of a second term as a formality - resignations are usually not accepted, though there is traditionally turnover between the two terms of a single presidency.
During Josh's (Bradley Whitford) rant to the staffer at the end of the episode he makes a reference to "favorite galaxies" in the Star Trek Universe, but every Star Trek series takes place in the Milky Way Galaxy. Ironically, however, this piece of trivia proves Josh's point.
"APEC" is the Asia-Pacific Economic Cooperation.