Julia Gardiner Tyler is believed to have first requested the song, popularized in an 1812 theatrical production of The Lady of the Lake, be played as a way to announce that her husband, President John Tyler, was entering the room.
The first time the song was played to announce a President at his Inauguration was on March 4, 1845, for President James K. Polk, Tyler's successor. First Lady Sarah Childress Polk is credited with formally tying the anthem to the arrival of the President to events throughout Polk's years in office. This tradition continued long after Polk left office and according to the Library of Congress website, "in 1954, the Department of Defense established [Hail to the Chief] as the official musical tribute to the U.S. President."