I do it all the time.
One common explanation traces the phenomenon to ancient pagan cultures such as the Celts, who believed that spirits and gods resided in trees. Knocking on tree trunks may have served to rouse the spirits and call on their protection, but it could have also been a way of showing gratitude for a stroke of good luck.”
[Source, History.com. https://www.history.com/news/why-do-people-knock-on-wood-for-luck ]