dnd 5e – Does a paladin have to announce that they’re using Divine Smite before attacking?

Starting at 2nd level, when you hit a creature with a melee weapon attack, you can expend one spell slot to deal radiant damage to the target, in addition to the weapon’s damage.

No, you do not have to announce it before attacking, it says “when you hit” so you get to choose whether or not to use it when you hit.