After quite a bit of research in the past, I could find no US Law or official document governing the flying of the US Flag on boats. Although there are publications out there, there really is nothing "OFFICIAL." After reading many of these publications (some contradict each other), here are the conclusions I've drawn:
1. The top, aft, and starboard are the positions of honor.
2. The US Flag, if flown from the backstay on a non-gaff rigged vessel, should be 2/3 the way up the backstay.
3. The best proportions (in most cases) for the US Flag are 1" fly for every 1-foot of boat length. There should be no other flags flown on the vessel that are larger than the US Flag.
4. The US Flag is not normally flown when under sail except where required by law.
5. The US Flag is flown from 0800hrs until sunset.
Thus, when at anchor or port, you could use your main-halyard (or halyard for your aft-most mast) to hoist a US Flag. Obviously, you would need to lower the flag before you set sails.
From one that has served our country for over 25-years, I'd like to say that I'm extremely happy to see the US Flag proudly displayed on any vessel. I am not offended when I see Old Glory flying after sunset or before sunrise. I'm not offended when I see Old Glory flying from a port spreader, as long as it's the only flag on the boat. I'm not even offended when Old Glory is obviously well out of proportions for the size of the vessel. However, I do get upset when I see Her so weathered and torn that only the field of blue and stars remain. And, I get down right angry when I see any flag hoisted above the US Flag.
Skipper, J/36 "Zero Tolerance"