This seems somewhat related though: https://www.sageadvice.eu/2017/02/14/do-you-have-to-declare-sneak-attack-or-divine-smithe-beforehand/ meaning that you would declare before damage.
This is the correct answer. "On a hit"/"when you're hit" happens before damage is rolled. The key tweet is this one: "(1) You make an attack roll. (2) You hit or miss. (3) You roll damage if you hit. "When you hit" happens at number 2." which is based on the rules for Making An Attack:
Whether you're striking with a melee weapon, firing a weapon at range, or making an attack roll as part of a spell, an attack has a simple structure.
1. Choose a target. Pick a target within your attack's range: a creature, an object, or a location.
2. Determine modifiers. The DM determines whether the target has cover and whether you have advantage or disadvantage against the target. In addition, spells, special abilities, and other effects can apply penalties or bonuses to your attack roll.
3. Resolve the attack. You make the attack roll. On a hit, you roll damage, unless the particular attack has rules that specify otherwise. Some attacks cause special effects in addition to or instead of damage.
You could think of "hit" as a "phase" of its own. I think the game uses these:
You declare attack - targeting
You roll the attack - attacking
You determine if you hit - hitting
You determine damage - damaging
The damage part can be broken down further into two steps - making the damage roll and applying the damage. A Lore Bard's Cutting Words and the Savage Attacker feat modifies the value of the damage roll before damage is applied, while spells like Hellish Rebuke kick in afterwards.