Since the headset bearings tend to be always around the same position while riding (because the headset does not spin, except for those performing barspins), and we rarely disassemble them, sometimes the spheres create depressions on the bearing tracks. This creates a "stable" position when the front wheel is pointing straight ahead, but sometimes this self-centering is to another (non-straight) position.
To check this problem, lift the bike from the top tube in normal riding position, and try to gently take the handlebar slightly away from this position. If the bike tends to "self align", the most probable cause is this "marked" headset. Fully disassemble and clean the bearings to perform a visual inspection is the only way to be 100% sure.
To solve the problem, these sequential steps should be taken. If the former step didn't solve, go on to the next:
- Loosen the headset just a little bit, letting it tightened just enough to prevent play when braking. This solves the problem sometimes;
- Open it (no need to disassemble) just enough you can spin the spheres out of position. Do this for the upper and lower bearing;
- Fully disassemble (including remove the cups from the frame), clean and remount in a different position;
- If neither of these solves, replace the headset for a new one.
EDIT: take away the handlebar and perhaps the front brake, and perform some barspins, to reorient the spheres. This could be the "Step 1.5"
Hope it helps