Knocking on wood, and the spoken expression "knock on wood" or "touch wood" are used to express a desire to avoid "tempting fate" after making some boast or speaking of one's own death.
The expression is usually used in the hope that a good thing will continue to occur after it has been acknowledged. So, for example, one might say: "The rain looks like it's holding off, touch wood", or "Knock on wood, I'm much better now.". Another Example would be "I have never had to use my gun before, touch wood".