As another (detoutcoeur) has already posted, you are probably thinking of 2 Maccabees 15:11-14, where Judas Maccabeus related a credible dream or vision that he had had of the former high priest Onias and the prophet Jeremiah, both deceased at the time, still praying for the Jewish community.
Though it does not seem to have been especially efficacious in this particular instance, what Jesus said in Luke 16:19-31, the story of the rich man and Lazarus, about the dead rich man and his attempt to get Abraham to send Lazarus to warn his living brothers is another Scripture passage that supports the notion that the dead can and do intercede for the living.
Other interventions by the deceased on behalf of the living can be found in 1 Samuel 28:19, where the dead prophet Samuel appeared to King Saul and prophesied the king’s doom, and in 2 Kings 13:21, where a man is raised from the dead when his corpse comes in contact with the bones of the dead prophet Elisha. Of Samuel the book of Sirach says in part, “Even after death his guidance was sought; he made known to the king his fate. From the grave he spoke in prophecy to put an end to wickedness.” (Sirach 46:20) Of Elisha it says, “In life he performed wonders, and after death, marvelous deeds.” (Sirach 48:14)