If the hardware allows, you can perform a reset directly on the PLC's screen.
Buy a second, identical memory card. After commissioning, power down the PLC and clone the card using a card reader and TIA Portal. Store this clone in a safe. If a password is lost, you can swap the card and reload from the backup.
Before attempting a reset, you must understand what you are up against. The S7-1500 series (firmware version 2.0 and above) uses a multi-layered protection system.
TIA Portal V17 and later allow you to store passwords in an encrypted “Project Vault.” Link this vault to a physical USB dongle.