Knocking on wood - in Britain and Australia the phrase is touch wood - is an apotropaic tradition of literally touching, tapping, or knocking on wood, or merely stating that one is doing or intend to do so, in order to avoid "tempting fate" after making a favourable observation, a boast, or declaration concerning one's own death or other unfavorable situation beyond one's control.
The origin of the custom may be in Germanic folklore, wherein supernatural beings are thought to live in trees, and can be invoked for protection.
In Iran, "Bezanam be Tachte بزنم به تخته" (knock on wood), when one says something good about something or somebody, he/she will knock on the wood, saying "bezan-am be takhteh, cheshm nakhoreh" ([I] am knocking on the wood, to prevent -it, he, or she- from being jinxed). Evil eye, and being jinxed is a common phobia and superstitious belief in Iranian culture. Iranians traditionally believe knocking on the wood wards off evil spirits.
In Egypt, "Emsek El Khashab إمسك الخشب" (Hold the wood), people say it when mention good luck that you have had in the past or when you mention hopes you have for the future. The expression is usually used in the hope that a good thing will continue to occur after it has been acknowledged. And to prevent Envy
In old English folklore, "knocking on wood" also referred to when people spoke of secrets – they went into the isolated woods to talk privately and "knocked" on the trees when they were talking to hide their communication from evil spirits who would be unable to hear when they knocked. Another version holds that the act of knocking was to perk up the spirits to make them work in the requester's favor. Yet another version holds that a sect of Monks who wore large wooden crosses around their necks would tap or "knock" on them to ward away evil.
In Romania, there is also a superstition that one can avoid bad things aforementioned by literally knocking on wood ("a bate în lemn"). Wood tables are exempted. One of the possible reasons could be that there is a monastery practice to call people to pray by playing / knocking the simantron.
In Bulgaria the superstition of "knock on wood" (чукам на дърво) is reserved for protection against the evil, and is not typically used for attracting good luck. Usually people engage in the practice in reaction to bad news, actual or merely imagined. In most cases the nearest wooden object is used (in some areas, however, tables are exempt); if there are no such objects within immediate reach, a common tongue-in-cheek practice is to knock on one's head. Knocking on wood is often followed by lightly pulling one's earlobe with the same hand. Common phrases to accompany the ritual are "God guard us" (Бог да ни пази) and "May the Devil not hear" (Да не чуе Дяволът).
In Croatia and Serbia there is also the habit of knocking on wood when saying something positive or affirmative about someone or something and not wanting that to change. Frequently the movement of knocking on nearby wood is followed by "Da pokucam u drvo" (да куцнем у дрво) (I will knock on wood), or sometimes by "Da ne ureknem" (да не урекнем) (I don't want to jinx it).
In Poland, as well as in Russia, there is a habit of knocking on (unpainted) wood (which may be preceded by saying odpukać w niemalowane drewno or simply odpukać, literally meaning to knock on unpainted wood) when saying something negative - to prevent it from happening - or, more rarely, something positive - in order not to "spoil it". In Czech Republic, this is often accompanied for stronger effect by knocking on one's teeth, a piece of building stone, or metal, reasoning that these (as opposed to wood) survive even fire.
In Turkey, when someone hears about a bad experience someone else had, he/she may gently pull one earlobe, and knock on a wood twice, which means "God save me from that thing."
In Spain "tocar madera" (literally: to touch wood) is something that you say when you want your luck or a good situation to continue. Ha ido bien toda la semana y, toco madera, seguirá bien el fin de semana. (It's been fine all week and, touch wood, it'll stay fine for the weekend).
In Brazil, "bater na madeira" is something actually done phisically, three knocks are required after giving an example of a bad thing eventually happening. No verbalization is required, just the three knocks on the closest piece or object of wood. In the absence of wood, someone can say "bate na madeira", to prevent the bad thing to happen. People doesn't actually believe knocking threee times a piece of wood will really protect them, but it is a social habit and it is polite to do so to demonstrate that ones doesn't want that bad thing they are talking about to actually happen.
In Greece the saying "χτύπα ξύλο" (literally: Knock wood) is said when hearing someone say something negative in order to prevent it from happening.
In Lebanon the saying "دقّ عالخشب" (literally: Knock on the wood) is said when hearing someone say something negative in order to prevent it from happening. It is also largely observed when saying something positive or affirmative about someone or something and not wanting that to change.
In Palestine the saying "دقّ عالخشب" (literally: Knock on the wood) is said when someone mention good things happening to himself or someone else, or even when mention a valuable things he owns this expression is a superstition that is used in the hope that a good thing will continue to occur even after its mentioned. as a way to prevent Envy (Hasad "حسد") as Known as Evil Eye (Ain "عين") as they believe that Envy can harm other people.
^Reference.com: Origin of Knock on Wood. The origin of knocking on wood for this purpose is believed by some to be from early pagan mythology. Wood gods, or dryads, lived in trees, and people would go to them for blessings and to prevent bad luck.
^Touch Wood for Luck: The History & Superstition of 'Touch Wood'. One explanation states that the tradition derived from the Pagans who thought that trees were the homes of fairies, spirits, dryads and many other mystical creatures. In these instances, people might knock or touch wood to request good luck, or to distract spirits with evil intentions. When in need of a favour or some good luck, one politely mentioned this wish to a tree and then touched the bark, representing the first "knock." The second "knock" was to say "thank you." The knocking was also supposed to prevent evil spirits from hearing your speech and as such stop them from interfering. Alternatively, some traditions have it that by knocking upon wood, you would awaken and release the benevolent wood fairies that dwelt there.