A lot of people are superstitious. Some people believe that talking about how well something is going will bring bad luck. In the example above, the speaker says that his car hadn't had any problems. So he's worried that, after saying that, his car will soon break.
Tapping on a piece of wood is supposed to get rid of this bad luck. People say "Knock on wood" when they're hitting the wood. Sometimes they say it when they're not actually knocking on any wood, as well. Either way, it's a way to avoid having bad luck.