Dobby the house-elf dies in Chapter 36: The Flaw in the Plan of Harry Potter and the Deathly Hallows.
He is fatally wounded by Bellatrix Lestrange's knife while apparating Harry and his friends to safety from Malfoy Manor. His final words are "Harry Potter", and he is buried at Shell Cottage without magic—Harry digs the grave manually to honor Dobby's freedom.