Enzymes have a more or less narrow optimal pH at which they work, depending on the conditions of their environment. Pepsin for example is active in the stomach which is pretty acidic and has an optimal pH of 2.0, while Trypsin, which is active in the small intestine has an optimal pH around 8.5.
Changes in the pH first affect the form of the protein, hydrogen bonds between the amino acids of the molecule and so on and also the form of the active center of the enzyme. Small changes in pH do little or nothing, then reversible changes occur and finally the enzyme gets irreversibly denaturated.
The relationship between enzyme activity and pH always looks like this (the curve can be steeper, if the optimal range is small and broader if the range is wider):
It is taken from this website, which is a nice introduction to enzymes. Another one is here.
At the optimal pH for the enzyme the conformation of the protein is as it should be (in the ideal state) while this changes when the pH is not optimal. This can lead to improper substrate binding, changes in the active center and so on.