You're likely thinking of The Sixth Sense (1999):
Child psychologist Malcolm Crowe (Bruce Willis) treats Cole (Haley Joel Osment), who sees dead people. Crowe is haunted by the ghost of his ex-patient Vincent Gray. The climax reveals Crowe accidentally killed Vincent as a child—and Vincent's remains are hidden under Crowe's fireplace.
The discovery reframes the entire narrative. Other films with similar tropes exist (The Others, The Changeling), but The Sixth Sense is the most famous.