That functionality only works when the game server allows cheats. In single player, you can create the game to allow cheats. Failing that, you can use the game options to start up your single player world in LAN mode, enabling cheats while you do so.
After doing this, the button should be...