When you say out of sync I assume this means that when you look down while on the bike the handlebars point one direction and the wheel points in a slight different direction.
You say locknut so that implies a threaded headset. If so, simply loosen the bolt on the top of the stem and realign the stem with the front wheel while straddling the bike. Note this will also now allow the stem to lower down into the frame so be sure to first mark the height with a piece of tape. Threaded headsets are no longer the norm except on low end bikes and older bikes. Adjusting the lock nut and headset requires a pair of large open-ended wrenches.
If the stem has bolt on top (when you look down on it while riding) AND at the back of it. Then you have a threadless headset. These have been the norm on most bikes for the past ~25 years. The "locknut" you're referring to is the bolt on top of the stem (this bolt holds the fork/frame/stem/headset bearings together and keeps them properly compressed)***. If this is the case then all you need to do is loosen the bolt (or bolts - could be 2) which will allow you to swing the stem and bars left/right. Line the stem with with the front wheel while straddling the bike and then tighten the bolts. Take care not to over tighten the stem bolts! Don't go gorilla with the wrench (this rule applies to almost anything on a bike!) Given the safety repercussions of improperly adjusted stems it would be prudent to have a trained bike mechanic double check your work.
***If you did monkey with the top bolt you may have messed up the adjustment of your headset bearings. Don't panic, it's an easy fix:
- Loosen that top bolt however many turns you think you tightened it and maybe a few extra. Also loosen the bolt (or two) at the back of the stem.
- Set the bike on the ground, stand next to it and turn the handlebars 90 degrees. Now squeeze and hold the front brake. Don't let go.
- Try to roll the bike back and forth. You should feel a slight knocking sensation. This is play in the bearings (bad!)
- Tighten the top bolt a half turn. Repeat steps 2 & 3.
- Repeat step 4 until the knocking sensation is gone. Key here is to adjust the top bolt in very small increments until the play/knocking is just removed. Any tighter and you'll create binding which will prematurely wear out the bearings.
- Tighten the bolt or bolts at the rear of the stem.