Membrane potentials are caused by different concentrations of ions on opposite sides of membranes in micro-environments along the membrane. The membrane can be, overall, electrically and chemically neutral with small areas that have differences in electrochemical gradients.
For cells to produce these potentials they have proteins embedded in the lipid membrane. Ion pumps are the main players in creating potentials and gradients; through active transport (the use of ATP) the protein moves ions from one side to the other. When the concentration of that area of membrane is at one concentration the proteins are held in one conformation (active or inactive) and when the gradient is changed or meets a threshold the protein changes conformation and becomes activated or inactivated. So the actual electrochemical gradient dictates when the proteins are transporting.
There are also other proteins/messengers that are produced which can interact with the transmembrane proteins that keep them in one configuration or another to facilitate the production of an action potential. Once again, when this specific concentration is met the signaling molecule/transporter will become inactivate or activated.
This is just stuff I recall from some classes. Honestly, wikipedia is a fine general knowledge source. And more detailed than my explanation. http://en.wikipedia.org/wiki/Membrane_potential#Ions_and_the_forces_driving_their_motion