There are a number of bugs that appear during their larval stage like minute black worms. Most of these feed on decaying organic matter, and have likely found their way beneath the kitchen sink because there is something like that present. It could be dirt or mold, or even a piece of wet cardboard. The other reasons bugs find their way in is in search of water or for shelter as winter approaches.
These are black worm-like creatures with as many as 400 legs. Their 1- to 1 1/2-inch body is encased in armor, and when disturbed or frightened, or when they die, their exoskeleton curls, or spirals inward. Often found in basements, they may also find their way into cupboards and beneath sinks. They feed on decaying organic matter, and usually invade homes prior to cold weather, or during very wet weather, looking for a warm or dry place to hide. Millipedes are harmless, but can be something of a nuisance.
Resembling wasps in appearance, soldier flies possess no stinger and are harmless. They prefer moist locations, and on the occasions that they become trapped inside the home, they will nest in areas that are damp, like beneath the kitchen sink. Their larva looks like small black worms, and they will scurry away from light when you open the door.
Also called moth flies, these insects do appear more like gnat sized moths than they do flies. They are covered with fine dust like moths, as well. They breed in the bio-film present inside drains and sink traps, and often come out in force when the home has been vacated for short periods of time. They also feed on organic matter. Drain fly larva are little black worms that may be seen wriggling up out of the drain itself, or may be found at any place in the kitchen or bathroom where there is moisture and a food source.
Whatever the black worm is, control can likely be achieved through sanitation. Clean out the underneath of the sink, and remove any debris, such as damp boxes, dirt or mold. Check that there are no leaks from the plumbing, as this often causes bug infestations in the home. Dry the compartment out thoroughly, and even allowing it to air dry by keeping it empty and the doors open for a few days may help. You may also put down some commercial insecticide if a routine cleaning does not rid you of the problem.