Guitars can go out of tune for a number of reasons. These reasons include problems with the guitar hardware set up. Assuming that the strings have been put on correctly and that they are relatively new, the thing to look at is the hardware and the route that the strings take from the tail piece to the machine head. There are some tricks that can help stop strings sticking during the tune up process.
If you hear a chinking sound when you tune up your guitar it is likely that a string is sticking on the hardware somewhere along its length. This sticking can suddenly be released when you are playing making the instrument go out of tune. The obvious places where this might happen include the bridge, the neck nut and string trees in the case of fender guitars. Look at the following items, which give details of how to set up a guitar that will stay in tune.
The first item to look at is the neck nut. You can lubricate the path of the string through the grooves in the nut with graphite. All you need do is sand some pencil lead and collect the graphite dust. This can then be dropped into the nut grooves. The graphite will lubricate the string in the groove and help to stop it sticking. Likewise you can put graphite on the under side of any string trees on the head stock.guitar hardware Do not be tempted to use anything like oil to do the same job as this will affect the wood parts of the guitar and damage the fret board finish if it is lacquered. If you think that the nut is no longer serviceable, then you can get a graphite nut fitted which will automatically lubricate the strings.
You should check the bridge saddles to ensure that they are corrosion free, especially where the strings pass over them. Corrosion can be a problem on bridges because of the amount of sweat that can end up on them, due to damping with the right hand while playing. If corrosion is evident you should try to remove it with a small stiff brush and a little light oil on a cloth. Try not to get this on any of the painted parts of the guitar.
Another place to check is the machine head itself. Most machine heads have a central screw that passes from the back of the machine head body and into the tuning peg. This screw can become loose after a lot of use. You can check this by seeing if the tuning peg wobbles once you have removed the string. If the tuning peg is loose you should remove the machine head by taking out the screws on the back of the head stock. You can then tighten up the loose screw and refit the machine head. By setting up a guitar to stay in tune you can make sure that you enjoy your playing.