If I am playing lead for song on the spot, and I play a solo using a G major scale, can I start with a G and end with some other note (such as a D for example)? Or is it necessary to end on a G to stay in the G major scale?
Short answer: It doesn't have to start or end with anything. The last note ending on a G might end up feeling more resolved, but you can use any note you'd like to end on that you feel sounds like it meets what you want to accomplish the solo. If I know another musician is taking a solo right after me, sometimes I'll deliberately end on the 5th (in this case the D) and let them pick it up from there so I build tension and let them resolve it.
As long as you play within a G major scale you still are in G major. However it should be noted that starting and ending on a G will have the effect of making the G feel like the home note (known as a tonic) which is what you want if you are playing in G major. It's not a bad thing to end on a different note and it can have interesting effects.
On thing you have to be careful with overall is make sure none of the other notes of the scale feel like the tonic as this will make the solo sound more like a mode based on G major.
In classical music theory you can sometimes start a piece on the dominant when an upbeat or Anacrusis is used. Seeing as the lead would generally be somewhere in the middle then maybe this should not be the case.
It is good to use cadences in the middle of pieces that do not end on the tonic. The tonic is very unique in the way which it indicates finality. I would try to use this feeling of ending only at the end ( You don't say (-: )
That is at least how classical melody writing would work. I think it is still relevant to solo work,.
The short answer is no. But what is your intent? Do you want the listener hanging on for something next or do you want to resolve the phrase? You should search for Call and Response and Tension/Resolution in music in your favorite search engine. Also, listen to other solos in the genre you like and transcribe what their doing. It will help understand how they express the feeling of Tension/Resolution. Blues is a really good start while using a simple Pentatonic Scale and understanding phrasing.