In some places, apartment owners change locks after renting out the apartment if they don't have a particular trust with the tenants. (I seem to recall that with some kinds of mechanical locks it's possible to change the matching key without replacing the entire lock—not by yourself though, you call a specialist mechanic for that.)
And afaik hotels these days routinely change ‘keys’ that open electronic locks, every time a guest checks out. (Not sure about the mechanics: either info on the key card and lock is changed, or correspondence of RFID cards to the rooms.)
You could also consider storage lockers at train stations and such: they're sometimes set up with combination locks and you choose the combination when closing the compartment—even with mechanical combination locks.
The anticipated threat is the same in the three cases: people who had access to the lock but shouldn't anymore. This corresponds e.g. to changing passwords for shared accounts after an employee quits.