Moored, whether at anchor, to a mooring buoy, or at pierside, US Navy ships fly the Jack from the Jackstaff in the immediate bow. The National Ensign is also flown from its staff.
Underway, the National Ensign flies from a designated halyard on the main mast. The commissioning pennant, and the burgee of embarked Flag Officers flies from the foremast.
The process is part of setting the Sea and Anchor Detail, and you have signalmen (who are not going to let the deckapes touch their bunting) in all the locations needed. The talkers will pass the word on the JA circuit--"Shift the Colors"--so that this is coordinated.
It's my understanding that ships with stern cranes (not just ships with stern catapults) would have an alternate "in port" staff rigged for the National Ensign.
If steaming into combat, there was/is a long-standing tradition to fly the national Ensign from both Fore and Main mast, and fore and aft as well, in a 4, 2, 1, 3 configuration.
Which brings us to flag sizes. By Presidential order, USN flag sizes were regularized in sizes from 1 to 12, with 1 through 7 being the typical for ships, and 7 through 12 for boats and smaller vessels.
The No 1 flag is 20' tall in hoist, and 38' in the fly (±6 x 12m); the #7 5'-2" by 9'-9"; th #12 a mere 1'-3-3/4" by 1'-5-7/8" in size. The flags are issued in proportion to the size of the vessel, so DD might only have a #4 for it's largest flag dimension; a capital ship might carry a #4 or #5 as its smallest flags.
The largest National Ensign is often referred to as the "Sunday Ensign" for being broken out with the Church Pennant, when moored. it's also flown when a ship is "dressed"--having a hoist made of all the signalling pennants strung together and hoisted from stem to stern (the order of the flags differs between nations, too).
In case of need, here's a chart of sizes: http://www.history.navy.mil/faqs/faq129-1.htm