If you are getting earwigs in your sandbox then that could be a sign that there is a nest in the actual sand itself. Rake the sand and clean it, or replace the sand. You do not want there to be insects in the sand because it would affect the kids that play in the sand.  If you do not want to remove the sand then spray the sand with insecticide.

Mix equal parts of surgical spirit, glycerine and water. Repeat every two weeks for 3 months after earwigs have disappeared to catch stragglers. You can use hot soapy water if dealing with an infestation. This should be sufficient to solve your problem although this may require repeating over several weeks for best results.

Using earwig traps are another way to get rid of them. The traps are placed in strategic areas where they are often found outdoors under debris or piles of firewood.

You can make your own traps by filling a tall glass jar (food jars like those used for spaghetti sauces work well) with beer and placing it on its side near the area where you have seen earwigs. When the insects fall in, they will drown in the beer. Make sure to put several traps out as these pests are small and easily able to escape from an overcrowded trap.

Using insecticides is another option although this should be undertaken with caution because of children or pets that may come into contact with the poison; wear gloves when applying and keep kids and pets away until dry. Make sure to cover any areas outdoors where children play so they do not come into contact with them.