Answer:
In 2007, Congress addressed this for the first time in 36 USC 301. This U.S. Code therefore created the first mandated national anthem etiquette.
The pledge of allegiance should be rendered by standing at attention, facing the flag, and placing the right hand over the heart (the salute). Uniformed personnel, firefighters, law enforcement officers, and military personnel in uniform should render a hand salute.
When the national anthem is played or sung, U.S. citizens should stand straight and rigid 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 singer.