Rick has it.
Key had been sent to negotiate the release of a prisoner, a prominent doctor, held by the British. A small "flag of truce" sloop that he was transported on, was towed by Surprize to the Baltimore area, while Key was a "guest", aboard Surprize, Cochran's temporary flagship.
During the actual bombardment of Fort McHenry Key was placed back on the sloop, and it was anchored with the British transports, out of harms way, eight miles away from the action.
The next morning, Key scribbled a "few random lines" out of the emotions he felt seeing the American flag still flying and watching the British ships withdraw and the amphibious troops reboarding their boats. On the sloop's slow voyage home, the lines "gelled into a poem", which he set to the tune from To Anacreon in Heaven, which had already been used for several American patriotic songs.
It's fitting to have American sporting events open to the melody of an 18th century drinking song.
http://www.contemplator.com/america/anacreon.html
Cochran's Surprize was the 8th to carry the name and one of the many sister ships to Shannon.