From Daily Kos:
The union of politics and music has a long history. It works on a multiple levels too. Associating a campaign with a popular song is the equivalent of having a good jingle for a product, and it helps to get the crowds going.
Can a candidate use a song at a campaign event in front of the crowd before the candidate arrives?
• When music is played in public, such as at a campaign event, it is typically necessary to obtain a license for the musical composition (words and music). It is not necessary to obtain a license from the owner of the sound recording (usually a record label).
• The musical composition license is usually issued by a performing rights organization (“PRO” – such as ASCAP, BMI, and SESAC).
• The license can be obtained by either the campaign or the venue (e.g., hotel, restaurant, stadium).
From Future of Music
Cases get less clear cut when political campaigns use songs in a context that could be interpreted as an endorsement of particular ideas or candidates on the part of the artist. ASCAP offers this guide for music use by political campaigns [PDF], which outlines the process of clearing a song, and also explains how licensing a song may not protect a campaign from being sued by an artist who does not want them to use their music.