Here is a very clear description of how to conduct yourself
http://usflag.org/flagetiquette.html The instructions regarding conduct during the playing of the national anthem:
"The Pledge of Allegiance and National Anthem
The pledge of allegiance should be rendered by standing at attention, facing the flag, and saluting.
When the national anthem is played or sung, citizens should stand at attention and salute at the first note and hold the salute through the last note. The salute is directed to the flag, if displayed, otherwise to the music. "