Near the end, Holmes deduces that Dr. Grimesby Roylott has been letting a snake into his step-daughter's room in an effort to kill her and prevent her upcoming marriage, which would have a devastating financial effect on him. When Holmes attacks the snake with a cane, it retreats to Roylott's room and kills him instead. Holmes and Watson enter his room to find that "Round his brow he had a peculiar yellow band, with brownish speckles, which seemed to be bound tightly round his head." Roylott's "violent dealing" has literally "return[ed] upon his own head" in the form of the snake.
While there's definitely a similarity between the Psalm and the end of Holmes' adventure, I don't know whether this is just a coincidence or whether Conan Doyle created this situation in such a way that Holmes can draw this Biblical parallel.*
---
*A couple of Holmes' comments that I stumbled upon indicate that he does believe in God, which in turn suggests a familiarity with the Bible: at the end of "The Boscombe Valley Mystery," he says, "God help us! ... Why does fate play such tricks with poor helpless worms? I never hear of such a case as this that I do not think of Baxter's words and say, 'There, but for the grace of God, goes Sherlock Holmes'" and in "The Adventure of the Empty House," he says, "Halfway down I slipped, but by the blessing of God I landed, torn and bleeding, upon the path."