They didn't. It was Meaney and Siding who suggested it.Bashir and O'Brien actually sang a drunken duet, in "Explorers". Bashir never did that with Garak.
Another Bashir and O'Brien moment:
I didn't know what the song was. I had to look it up. The song is not rock, metal or pop.
The name of the song is "Jerusalem", an English Christian hymn, according to Memory Alpha.
It is curious that the writer chose a song from this genre of music.