This phrase is used to warn people to be careful what they say because other people may be listening.
It often refers to something said or done behind closed doors, usually something unsavory or something that one would like to keep hidden. So it can also be a caution against talking in case you are overheard.
It’s been around for a long time. A thirteenth century manuscript in Trinity College contains these words: “If these walls could talk they would tell you the story.” Sometimes, ‘walls have ears’ can suggest that someone, perhaps a nosy busybody, is listening on the other side of the wall. This person might even press a glass up to the wall so they can better hear what is being said. If ‘these walls have ears,’ then ‘these walls can talk.’
In action-adventure stories the expression is often used when one expects to find that the room has been bugged. But the phrase is a lot older than electronic listening devices.
This saying may come from a story about Dionysius of Syracuse (430-367 b.c.), who was a tyrant so hated that he altered the walls of many rooms in his palace so that he could hear what was being said from another room. Similar listening posts were installed in other palaces over the centuries, including the Louvre in Paris. In England, the phrase was first recorded in its present form in 1620.
In the time of Catherine de’Medici, wife of Henry II of France, certain rooms in the Louvre Palace were said to have a network of listening tubes so that what was said in one room could be heard in another. This was how the suspicious Queen discovered state secrets and plots.