A riff is a section of music that someone has written. While the musician may come up with the riff spontaneously before memorizing or recording it, a vamp is typically devised on the spot. Riffs provide a structure and focus to a piece of music. You use a vamp to provide an introduction to a subsequent, structured piece of music. James Brown frequently used to instruct his band to vamp until he was ready to begin a song. Vamps are regularly used in jazz as a means to let each player warm up and get the feel for a song. Riffs are distinct in that they should always be played the same.
Riffs can appear anywhere in a piece of music. Vamps are typically performed prior to the beginning of a song and in some cases, during a middle break-down section.
Since a vamp is typically used to build a live performance, they are less frequently committed to tape than riffs. In pop and rock music, riffs are regularly the feature point of a song. "Sweet Child of Mine," by Guns 'N' Roses, "Smoke On The Water" by Deep Purple and "Purple Haze" by Jimi Hendrix are well known for their distinctive and memorable riffs. Vamp sections are rarely the focal point of a song. The melodic content of a riff is usually more defined and obvious than the melodic content of a vamp. For example, the riff in "Paint It Black" by The Rolling Stones has a very clear melodic pattern. A vamp may allude to a melodic idea but rarely will musicians vamp the same idea over and over.
Both a vamp and riff are short, repeated sections of music, which can be played on any instrument. However, a vamp typically has a less formal and less rigid structure than a riff. You can develop a vamp as you play it, but a riff is typically the same each time.
A riff typically centers around a melodic motif, while a vamp centers around a groove. As the musicians vamp, they may improvise and embellish the original vamp and by the time they are finished, they are playing something entirely different to what they started with. Riffs, while they can be subject to slight variation, typically retain their melodic and rhythmic characteristics throughout a piece of music.