How can I lock a character's finger to his ear(earpiece) during animation

Yes, this could be done via some dynamic IK.

I remember Epic talking about changing the root of bones in control rigs for this sort of of thing in UE5, but I cannot recall where.

The UE4 method requires modifying your animation blueprint to add the ability to change the bone used for the hands IK to whatever you need it to be.

Then when the animation starts, you can set the hand IK bone to the head bone, and blend into it using an animation curve.

We use this method so that when a character reloads, their hand moves to their pelvis when putting away the old mag and getting a new one.