By flying slightly faster.
Note that the original, no headwind range won't be regained. Flying a bit faster in the headwind regains a little bit of the lost range.
More accurately:
Best range speed can be found from the power required graph. Draw a straight line from the origin to just brush past the power req'd curve. The airspeed at which the two lines touch is the best range speed.
For a headwind the best range speed can be found by moving the origin along the X axis the same amount as the headwind component (X axis scale is airspeed). The effect is to subtract the headwind component to give a 'shorter' speed scalar.
For a tailwind move the origin in the opposite direction.
If you've done it correctly you will see the speed increase with a headwind component and decrease with a tailwind.