To harmonize a melody, you simply play a chord which contains a note from that melody on the first beat of each bar. In time, you could also add another chord on the third beat of the bar. There is always more than one chord which could be used, but some sound better than others.
The more songs you learn and analyze, the easier it becomes to find the right chords to play. If you look at the scale and chords above, you will notice that the notes C and G appear in more than one of the chords. This means that if you were harmonizing a melody in the key of C, you could try both chords wherever one of these notes appear on the first beat of a bar. The following example shows a melody in C major harmonized with chords 1, 4 and 5. Learn it and then transpose it to all the other keys.
The table below shows the primary chords in all twelve major keys.
Although most melodies can be harmonized using only chords1, 4 and 5, it is also common to use one or more of the remaining chords ( 2, 3, 6 and 7) to create a different feeling. These other chords are called secondary chords. As with primary chords, the secondary chord chosen for the harmony in any given bar should contain the melody note which occurs on the first or third beat of that bar (wherever the chord changes). Here is the melody from the previous example harmonized with both primary and secondary chords. Once again, learn it and then transpose both the melody and the chords to all the other keys.