According to control theories (most having origin in the cybernetics), behavior is produced to maintain a certain sensed variable on a set-point (also called a refference point).
If the sensed variable is below the refference point, the organism will behave in a way that increases the sensed variable. If it is above the refference point, the organism will behave in a way that decreases the sensed variable.
There are many examples in the body - the sugar level (regulated by insulin and glukagon), body temperature (regulated by various means: sweating, shivering, taking clothes on or off, ...).
To sense a variable, the system must have a sensor for it. There are sensors for sugar levels, there are sensors for body temperature and all the other controled variables.
When it comes to hunger, I don't think there is a general explanation of how it works and I'm wondering why is that.
What might be the sensors for hunger?
They apparently don't have a lot to do with calorie intake, that is not measured directly. If it were, no one would be overweight. There seems to be a connection to the protein ratio in diet (protein rich diets beeing more satiating), and there certainly seems to be a conection to spent energy - exercise increases hunger, as well as periods of not taking food (basal metabolism spendig energy).
Thread: A homeostasis theory of hunger