In both creative and survival modes in Snapshot 13w16a, the XP bar changes colors depending on what items I have in my hotbar. For example, any item with an enchantment glint turns the XP bar purple, and spawn eggs change it to various other colors. It appears to change to the specific color of the last item I placed in it.
As far as I can tell, all one needs to replicate this is to place an item in the hotbar. It seems that either an enchanted item or something with alterable colors, like a spawn egg or firework star, will produce this effect.