Cast it on the character while the weapon is equipped. The cantrip will be applied to the weapon and last until long rest.