From a mechanical standpoint, only PCs earn experience - any that NPCs (including monsters) might earn is entirely DM perogative. If you want an NPC to expend XP via item crafting or spellcasting, assume it has enough XP to do so. I'd imagine, though, that most NPCs would be reluctant to do...