The heads are not identical. Each is specialized through adaptive radiation like Darwin's finches.
The heads may not be limited to types of food, but for any reason heads evolve: to set a pair of eyes further apart and higher, another head for hunting underwater, maybe one head just to attract a mate (that one wouldn't need to eat or think, just look attractive), and another head for communicating.
At birth the heads might not be differentiated.
Lobsters are born with matching claws, but as they grow older one becomes dominant and they develop into two completely different claws called a pincher and a crusher. The heads on your creature might be similar with one head naturally becoming dominant, and the lessor heads developing for secondary tasks (whatever they may be).