This question already has an answer here:
- Is a spell forever? 3 answers
When a wizard dies in the Harry Potter series, do all of their spells die with them?
When I say die, I mean get lifted.
For example, in Half-Blood Prince, after Dumbledore's death, this happens:
Harry heard Hagrid’s moan of pain and shock, but he did not stop; he walked slowly forward until he reached the place where Dumbledore lay and crouched down beside him. He had known there was no hope from the moment that the full Body-Bind Curse Dumbledore had placed upon him lifted, known that it could have happened only because its caster was dead, but there was still no preparation for seeing him here, spread-eagled, broken: the greatest wizard Harry had ever, or would ever, meet.
As a counterargument, we have the ancient but powerful protective enchantments placed around Hogwarts (probably cast by the founders of the school which were Godric Gryffindor, Salazar Slytherin, Rowena Ravenclaw, and Helga Hufflepuff). We also have the enchantments on the Chamber of Secrets, which were cast by Salazar Slytherin, and by the year 1992 (the 2nd year of Harry Potter whose book name is also The Chamber of Secrets), must have been at least 1,000 years old, but still effectively working. These 4 have been dead for hundreds of years, but their magic still exist in the modern Harry Potter world.