Yosemite Options
Things are a little different in Yosemite.
You can set the xbar symbol as auto-replace text in aware apps (such as Safari, Notes, TextEdit - but NOT Microsoft Office: see below).
To get the xbar symbol you can create a Unicode diacritical compound character (which overlays one character on top of another). The one you want is "overline" or "macron", which are Unicode Hex option0305 or option0304. To use Unicode Hex you need to have/add the Hex keyboard (System Prefs > Keyboard > Input Sources > add "Others" > Unicode Hex Input). This places a flag on the keyboard (e.g. US flag if your default keyboard is U.S.) and adds a Keyboard menu with the Hex keyboard as an alternative option (with symbol U+).
With the Hex keyboard selected, in a word processor, type the letter "x", and then holding the Option key, type 0305 (or option0304). If your word processor is capable of showing Unicode diacritical characters, you should now see the xbar symbol x̅.
Now for the clever bit: copy the compound character, and in Keyboard Preferences (now showing in the Keyboard menu) choose the Text panel, and add in the Replace column the letters "xbar". In the With column, paste your compound xbar character. Any time you type the letters "xbar" followed by a space or a pause (in a compliant App), MacOS will suggest the new character. You can reverse the substitution by clicking the cancel box, Escape, or Undo.
As Microsoft Office is not compliant, there is a second method for Word etc. In Word, choose Tools > AutoCorrect. There are two options here: in the AutoCorrect panel, you can type "xbar" in the Replace box, and paste the compound character in the With box. Alternatively use the Math AutoCorrect panel, and use "\xbar" in the Replace box to constrain its use just to "math regions" (Equation boxes). You could also check "Use Math AutoCorrect rules outside math regions" to use any of the preset commands within Word, but this substitutes many characters - so use cautiously. The substitution kicks in after a space, and can be undone with Undo.