As Obie pointed out in a comment, the expression speak of the devil and he shall appear is a remnant of a naming taboo that was taken very seriously in days long gone. Religions have known many more naming taboos. The Wikipedia article Names of God in Judaism points out that most English editions of the Bible use the phrase "the Lord", "owing to the Jewish tradition increasingly viewing the divine name as too sacred to be uttered." (See also Why Don’t Jews Say G‑d’s Name?.) In imperial China, there was a taboo on using the emperor's name. Somewhat similar is the prohibition against creating images of a god (or of living beings in general), notably in Islam. See for example the article The Religious Prohibition Against Images, which quotes the Sahih Muslim hadith:
He who creates pictures in this world will be ordered to breathe life into them on the Day of Judgment, but he will be unable to do so.
Finding the origin of such prohibitions, requires a theory about the origin of religion generally, and I don't believe there is a consensus about this topic in anthropology. One theory that is capable of explaining the above is the one proposed by René Girard (1923 – 2015), especially in his works La Violence et le sacré (1972; English: Violence and the Sacred) and Des choses cachées depuis la fondation du monde (1978; English: Things Hidden Since the Foundation of the World). I can only give an extremely condensed summary of his theory here.
In his earliest works, René Girard had explained that the human capacity to imitate ("mimesis") does not only help us learn things (see Aristotle's view on mimesis) but that it can also lead to conflict when one individual imitates another's desire for something. His next step was to ask what this insuppressible tendency to imitate would have meant for early human culture. The increase in brain size during the evolution from primates to hominids did not only imply a greater capacity to learn but also a potential increase in mimetic conflicts. Looking at a wide range of myths and religions, Girard used a process that may be described as abductive inference to arrive at the following hypothesis:
- Mimetic conflicts could escalate until they involved the entire group. This conflict of all against all could only end if one individual died as the result of this collective violence. Since the death of this individual brought back peace, this individual became associated with both the power to bring this peace and with the power to bring the preceding collective violence. This individual possessed nothing less than a godlike power. This process must have repeated itself many times until early hominids developed way of dealing with this, as described below.
- Ancient religious practices originate from an effort to deal with the collective violence. For example, instead of waiting for the next collective conflict, the community choses an individual and collectively kills it. The victim is strictly speaking innocent, but the collective murder turns him into the godlike individual that can cause violence and bring back peace. It is essential that the entire community believes in the victim's guilt, otherwise his death cannot bring peace because it would trigger revenge killings and more violence. Myths describing the death of individuals who brought certain things or benefits into the world leave no doubt about the victim's guilt.
- Since the sacrificed individual has dangerous powers, it makes sense to delegate this sacrifice to one or more individuals, who thus become "priests".
- Since the collective violence mentioned above is associated with all sorts of transgessions, it makes sense to delay the sacrifice of the chosen victim in order to allow or force him to violate all sorts of social rules (rules that would lead to collective violence if everyone violated them). This individual violates what some cultures call "taboo" and thereby establishes his guilt and justifies his sacrifice at the hands of the community or the priests.
- The chosen individual is associated with the power to bring violence, and hence is very dangerous. If he manages to exploit the fear he causes, he may be able to delay the sacrifice, stay alive and become a "god-king". This would be the origin of sacred kingship. Based on Girard's theory, it is no coincidence that kings were often considered as gods or their intermediaries (e.g. the Egyptian pharaohs).
- The meaning of the godlike victim was always ambiguous, i.e. having power over both peace and violence. This would explain why some languages have words that can mean both "sacred" and "cursed", e.g. the Latin word sacer. (The same ambiguity is still present in the French adjective sacré.) However, this ambiguity is difficult to tolerate in the long run, so cultures must either find excuses why "good gods" sometimes do bad things or make a distinction between "good gods" and "devils" (in Christian culture, Satan is a fallen angel).
- Early hominids seem not to have distinguished clearly (or not always) between a thing and its name. This would also apply to the godlike individual or victim mentioned above and hence also to kings. This would have given rise to naming taboos, which can apply both to "good gods" and "devils". It would expain why "the divine name [was] too sacred to be uttered" (to quote the Wikipedia article about Names of God in Judaism again).
The above theory does not explain the origin of all religions. It is a theory about describes the emergence of religious practices as psycho-social mechanisms to keep internal violence in check, not about religions that have a historical "founding father" (e.g. Christianity, Islam and Buddhism).
Note about the history of this answer: Within less than an hour of its submission, the original version of this answer was shortened to 36 percent of its original length on the grounds that it contained "unnecessary proselytising". The discussion in the chat led to questions and comments such as "Did I misunderstand something, or is the non-existence of any actual deity an unstated assumption in that entire theory?" (source) and "Preaching (or worse, treating as a natural assumption) the non-existence of any deity is equally much proselytising as preaching a deity-based religion" (source). The speed of the edit (within an hour), its size (74 percent) and its "justification" have led me to believe that the deletion was an attempt at censorship for faith-based reasons, with the argument about the answer's length serving only as a fig leaf. To the best of my knowledge, Stack Exchange does not approve of censorship.
The theory described above does not make assumptions about the existence (or non-existence) of deities; it is perfectly agnostic in this regard. (Even a theory that assumed the existence of a deity would still need to explain how belief in a deity (either the same one or a different one) came into the world.) The length of the answer is due to an effort to explain why an anthropological theory would claim that early humans would develop naming taboos, instead of simply stating that there is such a theory and be done with it.