"Hail to the Chief" is the ceremonial anthem for the President of the United States. Played by military bands (typically U.S. Marine Band "The President's Own") upon:
Music: James Sanderson (c. 1812), adapted from a Scottish boat song in The Lady of the Lake (Walter Scott). Lyrics by Albert Gamse (1900s), rarely sung. Duration: ~30 seconds. Preceded by four ruffles and flourishes (drum rolls + trumpet fanfares) for sitting presidents.
Not a law—tradition. The President can request alternatives (e.g., Reagan liked "California, Here I Come"), but "Hail to the Chief" remains the sonic signature of the office.