Where Did Knock on Wood Come from?

The term knock on wood has been around for many years. There is even a song entitled knock on wood. When people say that they have to knock on wood it is for luck. Knock on wood while the getting is good is basically what it means.