First of all, you should have a fairly good idea of the map layout. That way, you'll know what to expect, and from where. Learn common hiding places.
Stay out of his line of sight. Use available cover at all times. Don't just run around in the open. If you know there's a sniper nearby, take an alternate route and surprise him, or just avoid him entirely. Avoid choke points, as snipers usually cover those.
When a sniper is actively targeting you, move. Take your shots at him if you have to, but do not stand still. You're asking to get shot in the head if you do. Move unpredictably and chaotically. Jump, run back and forth, anything that you think he isn't expecting. He won't miss if he can predict where you'll be, so you've got to make sure he can't do that.
In that situation I personally would figure a way to flee and flank him. If you don't have a sniper rifle, you're at a disadvantage at a distance.