Knocking on wood used to be a way of warding off suspected impending bad luck, and now it's used as a tongue-in-cheek sort of phrase for when someone has had a lot of good luck, meaning that the person should be careful to avoid the bad luck which may follow.
Phrase finder always has the origins and meanings of all that stuff.
Knock on wood - meaning and origin. - The Phrase Finder