You can do this a easier way, create a world with no cheats and then open the world to LAN and enable cheats, this will activate cheats as long as the world is open with cheats. Then simply close the world and there will be no cheats enabled.
If you have a current world that was created with cheats then create a brand new world without cheats, then duplicate the previous world and use the
world.dat folder to replace the brand new worlds
world.dat folder and this will make it so there are no cheats, then use the trick listed above to enable cheats in the new world.