Yes. We are supposed to salute the flag during the National Anthem, with either a “heart salute” (right hand over the heart) or a military salute if you are active duty. Veterans are also permitted to present a military salute if so desired.
The United States Code (our giant collection of American law—laid out in great detail) contains the National Anthem Code and the Flag Code, but the two documents are not found in the same section of the U.S. Code. Portions of the Flag Code are frequently cited (on Memorial Day, Flag Day, and Independence Day), while the National Anthem Code is rarely mentioned at all.
The National Anthem Code and the Flag Code are laws, but laws predicated on honor and goodwill. No one is compelled to stand at attention and salute, or Pledge allegiance to the flag. Americans have, to borrow a phrase, free will regarding our public display of allegiance and affection for the Anthem and the flag, and indeed, some religious denominations forbid these American rituals.
I will not quote all of the National Anthem Code, but here is the part most people are interested in. Please carefully note Section 2. The National Anthem itself is the point of honor, so even if we cannot see the flag, we are to turn in the direction of the music, stand at attention and salute.
§301. National anthem
(a) Designation.—The composition consisting of the words and music known as the Star-Spangled Banner is the national anthem.
(b) Conduct During Playing.—During a rendition of the national anthem—
(1) when the flag is displayed—
(A) individuals in uniform should give the military salute at the first note of the anthem and maintain that position until the last note;
(B) members of the Armed Forces and veterans who are present but not in uniform may render the military salute in the manner provided for individuals in uniform; and
(C) all other persons present should face the flag and stand at attention with their right hand over the heart, and men not in uniform, if applicable, should remove their headdress with their right hand and hold it at the left shoulder, the hand being over the heart; and
(2) when the flag is not displayed, all present should face toward the music and act in the same manner they would if the flag were displayed.