Through a process called homeostasis.
If there is not enough glucose the pancreas secrete glucagon (a hormone) which causes the liver to convert stored glycogen into glucose.
If there is too much glucose, the pancreas release insulin. The insulin binds to insulin receptors on cells telling them to take in glucose. The insulin also tells the liver to convert glucose into glycogen.