actually, you can divide the process of improvisation :
1- find out the key of the part you're gonna improvise on.
Usually, in typical rock/pop songs, there is only one key per song.
The "key" means the scale that contains all the notes of all the chords used in this "part". For instance, a song with the chords G / C / Em is in E minor. It's quite easy to find the key. When beginning, you can just write down the notes used for each chord :
G major : G - D - G - B
C major : C - G - C - E
E minor : E - B - E - G
So you see, only the notes E - G - B - C - D are used.
Now, let's find a scale that contains those notes... You should of course check out some websites, the main scales can be found everywhere, even on wiipedia

There is a E minor scale, and the G major scale. Both of them uses the same notes.
The key of this song is G major, or E minor, depends on which chord sticks out more.
2 - choose a scale to play on.
You shouldn't necessarily choose the G major scale to solo : this scale contains 7 notes, where as only 5 notes are used in the chords.
G major scale : G - A - B - C - D - E - F#
When you're gonna hit the A or F# in the solo, they're not gonna be backed up by any chord. They're going to sound "exotic". Not necessarily bad, if you manage to fit them into a good melody.
But you could simply decide to play a sub-scale, such as the E minor pentatonic, that contains only E G B C D. No risk, the bet is safe.
3 - play the right notes from the scale at the right time.
During each chord, you don't have to play the five notes of the pentatonic scale : you could just focus on the 3 notes of the current chord. Because playing a 3-notes solo over one chord is very restrictive, you'll soon start to feel you could also add other notes. Notes which are in the pentatonic scale or not...
4 - trust your ears..
don't get stuck into a scale, try to ear a melody and play it.
a scale is just a backbone, the skeleton, that you know you can count on but if you play only those notes... then you're solo is goin to be too blend.
As a beginner, do steps 1 and 2, first. Learn the main scales, how they sound, etc. It takes about 1 or 2 years

Then step 3 and step 4 will come naturally, after listening to CD's, jams, etc.