The under 18 bit is actually civilian law. In the military you are under UCMJ and civilian law simultaneously. UCMJ charges can and will reference civilian law when not specifically addressed by the UCMJ. In fact, you can be charged twice for some things, if they overlap, once under civilian and once under military law. U.S. military members do not have protection from Double Jeopardy. And they will often go with the strictest state law - which is up to the 18th birthday.
Deployment rules are based on General Order Number One which is issued to the theater of combat. The big three deal with sex (outlawed entirely in some cases, they've loosened up in the past few years on that some, though), alcohol, and pornography. You break any of these and it's an automatic Field Grade Article 15. No questions asked. You can always tell if a group of soldiers just got back from deployment, because they'll be wearing faded ACUs, scored up desert boots, combat patches, and not enough rank to reflect all that. It's too easy to get in trouble in country.
Also, when all else fails, there is your own command. Orders are orders, if your command says 18 is the age of consent and that there will be no sex in country, or orders everybody to wear a big purple reflective armband, then you will do so. They can always make their rules stricter than regulations. Failing to obey an order is against UCMJ. (Now there are some pretty stupid orders given which the command cannot enforce and which are generally ignored, but don't assume anything if you want to be on the safe side.)