According to Project Britain's British Life and Culture it is lucky to touch wood:
Lucky to touch wood. We touch; knock on wood, to make something come true.
Where does this superstition come from?
Seamen/sailors in the 17th century would sometimes knock with their hands or tools on the wooden hull of their ship to listen for woodworm or rot, hearing a solid sound coming from wood in the hull would mean it was good to go(or ship shape)
When sailors were having a conversation and they would talk about good luck the sailors would sometimes say to one another that they needed to touch wood. (implying the ship ofcourse) This good luck could also be referring to the fact they made the journey this far on good terms and where hoping that their ship would finish its voyage fast and that their ship's hull would stay whole and strong.
In my country (the Netherlands) this superstition is also deeply embedded into our culture and we call it "afkloppen".
Afkloppen of aftikken is een vorm van volksgeloof en een ritueel waarbij oorspronkelijk op ongeverfd hout wordt getikt, om daardoor mogelijk ongeluk af te wenden, wanneer men zich verheugt over genoten geluk of wanneer iets geprezen wordt. dutch wiki on "afkloppen"'Afkloppen, aftikken', in: Folkloristisch Woordenboek van Nederland en Vlaams België/ K. ter Laan, 1949, pp. 7.
Translated this loosely means Afkloppen or aftikken is a form of folklore and a ritual which originally meant that you needed to knock or tap on a piece of unpainted wood to ward off bad luck, especially when you already had a string of good luck and would like that good luck to continue.
At first i thought this was mostly because my country has a deep naval tradition (along with some reasonable amount of European countries) spanning back some centuries. Looking further I found that most countries in Europe (and after looking at Wikipedia countries all over the world) have some sort of superstition/ritual implying that the knocking on or touching of wood seems to be a way of bringing good luck or to not "tempt fate"(jinx).
Wikipedia says that its rooted in German folklore but they are missing the citations needed to further investigate this claim. There is probably someone on this site that might be able to answer this. If anyone has some sources I would be happy to investigate this further