The phrase is old and appears in various Latin and Old English texts from the 16th century. The Italian writer Giovanni Torriano has the first recorded version in contemporary English, in Piazza Universale, 1666: "The English say, Talk of the Devil, and he's presently at your elbow."
Also, in 'Cataplus, a mock Poem', 1672 - re-printed in Hazlitt's Proverbs, "Talk of the Devil, and see his horns." Read more about the evolution of this phrase here.
When people say the phrase these days it is a reference to someone who appears unexpectedly while being talked about.