Totem usage can be detected using the MODIFIER_TOTEM constant of EntityDamageEvent. This does not currently support using the totem in the offhand because offhand is not implemented yet.