I believe that only deleting the .minecraft/mods/optifine.jar is necessary to fix this issue. If you delete that and it still doesn't work, then the url above mentions how to completely uninstall OptiFine.
It happens because the optifine.jar is shared in the .minecraft/mods/ folder between versions, so if you run optifine on multiple versions it will keep overwriting it, or causing an error since it's not the right version.