So what? Just because he cast the spell doesn't mean he should be immune to it. Odin's enchantment was>"Whosoever holds this hammer, if he be worthy, shall possess the power of Thor."
Odin isn't worthy, therefore he can't lift it. He could get around it before, but since the hammer has become sentient, he can't do it anymor.
The fact that he casts the spell doesn't matter, unless he knows how to undo it, which he clearly doesn't.