It simply knows which radial you are on. If you turn the OBS or HSI to within 90 degrees of the radial you are on it will tell you you are FROM the station. If you set the reciprocal of your present radial or any setting with 90 degrees of the reciprocal, it will say TO.
The airplane's heading does not matter.