This is a problem usually found in teenage boys and many women for slightly different reasons.
On thing to do is do more squatting (reg. oly. style) and make sure of the knee track in a mirror. The knees are always supposed to track in the direction of toe point in the squat and deadlift and the inner muscles in the thighs sometimes lag in development. Working on leg strength with the squats and "seeing" your knees track correctly or not may help your brain learn how to keep them in line. I'm not a big fan of using a mirror but in this case it can help.
You can also try placing a larger, light Swiss ball between your knees when doing squats or deadlifts as a physical cue to your brain that your knees are moving inward.
With my lifters, I have resorted to putting the backs of my hands on the insides of their knees shen they squat and push outwards when their knees start to press inward. You'll have to have a brave friend for that one.