My general rule of thumb is: If you can't sing the guitar solo or hum it, then it's not going to connect with listeners very well. I enjoy really simple and melodic musical phrases, a line that "Death Cab For Cutie" would use for example.
Most music/guitar teachers will say that a familiarity with most of the major and minor scales, as well as the pentatonic scale are necessary in order to write a guitar solo. I can see where they are coming from, but I can't say I totally agree. I have hardly ever used any theory when constructing a solo or riff myself.
So, what do I do?
- Listen: Listen for style. Is it "jazzy"? Is it sugar-candy "pop"? What is the vocal melody doing? These clues will give you an idea of where you should start. (You can play a punk-rock riff in a jazz song if you'd like, but you better be prepared for a lot of angry stares from the couples sipping their martinis in the Jazz club!)
- Absorb: Find a quiet place, and for goodness sakes, throw out the distracting boyfriend and the hyper dog. ( I know they are both adorable, but this step takes focus!) Let the music sink into your head and fill up your whole body. Focus on only the music. Then forget the music completely. Let your mind wander. (See what yoga is doing to me?)
- Speak: Based on what you have now heard and subsequently felt, what is it you would like to say musically? What can you add in this section of the song that won't take away from the beauty of the song? (Don't overdue it!) Has the whole song been really "busy" musically? In that case, you should try to play something really simple for contrast. How is your soul feeling based on the music? Are you sad? Use long drawn-out high notes or "drone" in the lower register of the fretboard.
- When in doubt, Follow the vocals: If I find myself completely stumped and uninspired, I listen to what the catchy vocal of the song is, imitate that melody slightly, or play a lick to compliment whatever has been sung.
- Simple is better then complicated: There have been so many occasions when I wanted to impress people and I would try to add a little "frill" or "run" that I couldn't quite play yet. Attempting to use techniques you aren't comfortable with never ends well.
I have to admit that whenever Dia tells me she would like a solo in a song I feel extremely anxious. However, I always feel a huge sense of accomplishment when I write a solo that I love and proceed to execute that same solo live. So all you need to do is remove all of the doubt that tends to creep up before you even remove your guitar from the case. Give it a try!