Sometimes this can be quite a difficult thing to do; sometimes it's easier.
One thing we can try is identify the 'home' note that the song 'wants to go to', and then try to tell if the song sounds 'major' or 'minor'.
Often this might be a common note in the piece, or a note that is sung at the end of lines.
In this case, we can see that 'G' is a common strong note in the piece. I also hear the piece as more 'Major' than 'minor' (some people would say that 'Major' is happy and 'minor' is sad, though it's more complicated than that!).
From this method, with your example, my guess would be that the key is G major, and that I could use notes from the G major scale.
Another method is look at the notes in the piece, and try to work out directly what key they fit in.
Here's a chart borrowed from this answer. (As Rockin Cowboy says, this chart is for Major Scales only. You can find similar charts on line for Minor Scales)

If we look at the notes in the piece, we can see only one 'sharp' - F#.
Looking at our table, we can see that agrees with our previous guess at the key - G major.
(It won't always be so easy, especially if you don't already have the notes written out with their enharmonically-correct names - but in this case, you do.)
So in your example case, we've used two methods, and both have given us the key/scale of G Major. Try it and see if it fits!