Yes, when you hear the Lord’s name taken in vain you should respond with a prayer of reparation, at the least.
Traditionally this is ‘Blessed be the name of Jesus.’ One could say a few of the Divine Praises, like, ‘Blessed be God. Blessed be His Holy Name, Blessed be Jesus christ, true God and true man. Blessed be the Name of Jesus.’
There is also the Golden Arrow Prayer:
The Golden Arrow
May the most holy, most sacred,
most adorable, most mysterious
and unutterable Name of God
be always praised, blessed,
loved, adored and glorified,
in heaven, on earth and under the earth,
by all the creatures of God,
and by the Sacred Heart of Our Lord Jesus Christ
in the most holy Sacrament of the altar.
The Golden Arrow was revealed by Our Lord Jesus Christ to a Carmelite nun of Tours in 1843 as a reparation for blasphemy.
Jesus said: “This Golden Arrow will wound My Heart delightfully, and heal the wounds inflicted by blasphemy.”