Always play in Tune.
Before you play your Guitar you have to put it in tune. This can be tuned manually by ear (hardest) or by using a Guitar tuner device (easier).
There are many things that will put your Guitar out of tune. Such as: Playing it, Changes in temperature and putting it in and out of cases or knocking it against something by accident.
Digital guitar tuners are a worth while investment. So get hold of one and watch the below tutorial on how to use one.