Practice a wide variety of scales, and learn them thoroughly. Most popular songs stick to traditional major and minor keys, so those are best to start with. More complex music such as jazz tends not to stick to one key, so you will need to have other kinds of scales at the ready.
Determine the key of the song. Many songs begin on the root note of the key they are in. If the song begins on G, then the song is likely in G major or G minor. Minor keys have a "darker" sound than major ones because of a flatted third and sixth in the scale.
Learn the song. Doing this will allow you to find an apt place for a solo within it. Popular places include repetitions of the verse and chorus, or at the "bridge," a section of new material that contrasts with the verse and chorus.
Determine what kind of scale would work best. If the song begins on G and has a dark sound, you will probably want to solo using one of the two G minor scales. However, if it is in G and has a lighter sound, you will probably want to solo using the G major scale.
Try the song again with different scales. Depending on the way the song works within its key, a modal scale may be applicable. Also, popular songs that operate within minor keys tend to apply either the blues scale or the pentatonic minor scale for solos. These two scales are harmonically similar.