you can also
-give a player a special tag when the player has a totem in main/off hand
-remove it when its not in hand,
-then do /scoreboard objectives add <name> deathCount and check if a player has both that and tag
(/execute if entity @p[tag=<tagname>,scores={deaths=1..}] run function <functionname>)
-but also make tag giving thing a tick late so that the check command can find the tag even a tick after the player has lost the totem