|When enlisting or at certain other times:"
I, _____, do solemnly swear (or affirm) that I will support and defend the Constitution of the United States against all enemies, foreign and domestic; that I will bear true faith and allegiance to the same; and that I will obey the orders of the President of the United States and the orders of the officers appointed over me, according to regulations and the Uniform Code of Military Justice. So help me God." (Title 10, US Code; Act of 5 May 1960 replacing the wording first adopted in 1789, with amendment effective 5 October 1962).
When commissioning and at certain other times:
During the Revolutionary War, the Continental Congress established different oaths for the enlisted men and officers of the Continental Army:
Enlisted: The first oath, voted on 14 June 1775 as part of the act creating the Continental Army, read: "I _____ have, this day, voluntarily enlisted myself, as a soldier, in the American continental army, for one year, unless sooner discharged: And I do bind myself to conform, in all instances, to such rules and regulations, as are, or shall be, established for the government of the said Army." The original wording was effectively replaced by Section 3, Article 1, of the Articles of War approved by Congress on 20 September 1776, which specified that the oath of enlistment read: "I _____ swear (or affirm as the case may be) to be trued to the United States of America, and to serve them honestly and faithfully against all their enemies opposers whatsoever; and to observe and obey the orders of the Continental Congress, and the orders of the Generals and officers set over me by them."
Officers: Continental Congress passed two versions of this oath of office, applied to military and civilian national officers. The first, on 21 October 1776, read: "I _____, do acknowledge the Thirteen United States of America, namely, New Hampshire, Massachusetts Bay, Rhode Island, Connecticut, New York, New Jersey, Pennsylvania, Delaware, Maryland, Virginia, North Carolina, South Carolina, and Georgia, to be free, independent, and sovereign states, and declare, that the people thereof owe no allegiance or obedience to George the third, king of Great Britain; and I renounce, refuse and abjure any allegiance or obedience to him; and I do swear that I will, to the utmost of my power, support, maintain, and defend the said United States against the said king, George the third, and his heirs and successors, and his and their abettors, assistants and adherents; and will serve the said United States in the office of _____, which I now hold, and in any other office which I may hereafter hold by their appointment, or under their authority, with fidelity and honour, and according to the best of my skill and understanding. So help me God." The revised version, voted 3 February 1778, read "I, _____ do acknowledge the United States of America to be free, independent and sovereign states, and declare that the people thereof owe no allegiance or obedience, to George the third, king of Great Britain; and I renounce, refuse and abjure any allegiance or obedience to him: and I do swear (or affirm) that I will, to the utmost of my power, support, maintain and defend the said United States, against the said king George the third and his heirs and successors, and his and their abettors, assistants and adherents, and will serve the said United States in the office of _____ which I now hold, with fidelity, according to the best of my skill and understanding. So help me God."
You can see more of the history of U.S. military oaths at the U.S. Army Center of Military History.