The main part of the brain that is responsible for the maintenance of balance in the body is the cerebellum. The cerebellum receives input that originally comes from the inner ear. Within your inner ear, you have a vestibule and semicircular canals that allow your body to determine where it is in space when it is still and when it is in motion. These structures then send the information about body position through the vestibular branch of the vestibulocochlear nerve (cranial nerve VIII) to the brain stem, specifically the vestibular nuclei of the pons and medulla oblongata. From there, other neurons take the information to other parts of the brain.
One region is the cerebellum. The cerebellum receives this input and then sends information about corrective measures that need to be made to the motor cortex (sends messages out to effectors, like skeletal muscles) so that balance can be maintained. The cerebellum maintains both balance and posture.
The information from the vestibular nuclei also travels up the thalamus (which is a processing and relay center) and to the vestibular area of the cerebrum, located on the parietal lobe near the lateral sulcus. Information received here is integrated with visual and somatosensory information (the stretching of muscles, for example) to provide a better picture of the overall spacial orientation of the body.