This video from the National Parks Service illustrates how to safely extinguish a campfire, as well as how to properly build and maintain one.
Tips & Warnings
Make sure you have access to a shovel and a sufficient quantity of water any time you build a campfire. If you are camping in the backcountry, learn how to find water in the wilderness
so you will be able to locate what you need.
Do not bury a campfire in order to put it out. This can still allow embers to be left smoldering beneath sand or dirt, with the possibility that any roots it can touch will ignite and start a fire.
Always be sure the campfire is completely extinguished and cool before you leave. Leaving behind any hot embers could lead to tragedy.