If your windshield is fogging up some days, but not others, then it may be that you are just not using your heater correctly.
1) Make sure that you have the heater in the defrost setting.
2) Make sure that you put the fan on a high speed setting.
3) Make sure that you set it so the heater will bring in outside air.
If it is a cold rainy day and you have several wet passengers in the car, the windows will often tend to fog.
If the above three actions do not clear the fogging, you may have to wait for your engine to reach full operating temperature before the fogging will disperse.
If none of the above clears the fogging, then you may have a defective thermostat in your engine which will necessitate servicing.
Note that it is possible for windows to fog on the outside on very hot humid days if you have the air conditioning on full and using the defrost setting. This is caused by the air conditioner blowing large volumes of cold air on the window which causes the air outside of the car to condense. It will usually come off with the windshield wipers. If that is happening, then try to switch the air conditioner so that it is blowing towards the floor rather than the window.