When you first create a world in Minecraft, you can decide whether you want to enable command line cheats or not. The setting is no longer accessible from the main menu once you have made the decision to use them or not. Is it possible to enable cheats for a level if you did not enable them when the world was created?
There is no setting in the menu that will allow you to enable cheats again, but it is possible to change the game state that allows you to temporarily enable them in order to make use of the cheats. If you pause the game by pressing the escape (ESC) key, you will see there is an option to enter a LAN mode. When you click this, you can enable cheats for the LAN game. Once you do this you can use the game cheats as normal. Once you go back to a non-LAN game the cheats will be disabled again, but you will get to keep everything that you gave yourself while cheats were enabled in LAN mode.