First, the instrument needs to be properly intonated. That is, each bridge saddle needs to be adjusted so the string crosses it at the correct distance from the nut.
This is relatively easy to do yourself. In a nutshell, you start by putting on a new string set and, with a tuner plugged in, compare a note played open with a note played at the 12th fret for each string. If the 12th fret note is flat, you want to shorten the string length, which you do by adjusting the corresponding saddle with a screwdriver, moving the bridge piece in the direction of the neck. If it’s sharp, you want to lengthen the string length by turning the screw in the opposite direction, thus moving the saddle towards the end of the body, away from the neck.
Some guitarists find this process easy to do, while others prefer to let a repairperson take care of it. If the nut is cut too high, too deep, or too tight it too can cause intonation problems, and correcting this is something you definitely want to take to a pro.
Old, crusty, or rusty strings are difficult to get in tune, and you will want to put new strings on before you intonate, because if it is done with old strings, the intonation will be off when you put on new ones.
After putting on new strings, you need to stretch them by pulling gently along the length of the string. Not once, but five or six times, until they stop going flat when you pull them.
When winding on new strings, make sure the second wind passes over the first, and that the winds go neatly down the tuner. Three or four winds for non-wound strings and two or three for wound strings should be plenty. When you stretch them you are tightening these winds so they don’t tighten further when you bend a string, causing notes go flat.
If your guitar has a vibrato arm, every time you dip the arm the winds loosen, only to tighten when you release the bar. Minimal winds make it more likely they will come back to the proper degree of tightness. That is why locking tuners, which require no winds, help vibrato-equipped instruments stay in tune.
Serious frustration can occur when you put a fresh set of strings on a perfectly intonated guitar, stretch them properly, and it still sounds out of tune. On rare occasions, a single string in a new set doesn’t vibrate properly. If you are sure everything else is correct, try to isolate the string by playing chord voicings that leave out one string at a time. You should be able to find the culprit and change just that string.
The guitar is an equal-tempered instrument. While there isn’t space to go into what that means here, suffice to say if some chords are perfectly in tune others will be out. Guitarists normally set up their instruments with an equal, minimal amount of out-of-tuneness throughout the fretboard. A Buzz Feiten system perfects the tuning by relocating the nut and using a unique intonation at the bridge.
Even with new strings and an ideal setup, you may still have intonation issues unless you learn the art of playing in tune. Experienced players subconsciously push and pull strings into tune as they play. Tales abound of Jimi Hendrix and Jeff Beck picking up seemingly out of tune guitars and playing them perfectly in tune. This is why a repairman to the stars, who knew everything about getting a guitar in tune, had me play parts on his recordings—I could play them more in tune than he could.
Take it easy
Another, often unrecognized, issue is players who push too hard, and unevenly, with their fretting fingers, causing some strings to go sharp. You only need enough pressure to make a solid connection between string and fret. Acoustic players who take up electric can have this problem, as they are used to pressing down much heavier strings.
When in doubt, sell
Unfortunately, no matter what you do, there are some guitars that will never sound completely in tune. I had a Buzz Feiten system installed on an Epiphone Riviera reissue and it still didn’t sound as in tune as my 1965 Stratocaster without the system. This was because the Strat’s overtones vibrated more harmoniously. This is a function of an instrument’s materials and construction. It contributes to making a guitar sound great or meh, and has little to do with cost—my Fernandes Strat and Tele copies consistently sound beautifully in tune. If you heed the advice above and the instrument still doesn’t sound in tune, do yourself a favor and sell it.