Many people assume that the queen controls everything. She doesn't. The only thing she actually controls is reproduction. Queens create a chemical called queen substance or queen pheromone. The retinue of worker bees that feed her spread this queen substance around to the other workers in the hive, and as long as there is enough of it, none of the workers' ovaries develop. In addition to this, the queen internally controls whether an egg is fertilized (is female) or unfertilized (is male).
Externally its a different matter. Workers actually control whether or not the queen lays fertilized or unfertilized eggs by the size of the cells they build. Smaller cells induce the queen to lay fertilized eggs, larger cells are a cue to lay unfertilized eggs. Queen cups also induce a queen to lay fertilized eggs, which are created by workers when the levels or queen substance produced by the queen become too low (usually when either the queen is getting too old, or when the hive gets too big.)
or, workers decide when to change the queen bee