I think it depends to some extent on the magnitude of the error, and the complexity of the correction.
If you have found a serious error in one of the results, and the correction involves major changes to the proof, or requires a significantly stronger hypothesis or weaker conclusion, then I agree with the other answers that you should contact the editor and ask that the corrected version be sent to the referee (include a list of the changes you made). Otherwise the referee may waste a lot of time sorting it out, or just reject the paper.
If you have found some typographical errors, or a stray factor of 2 in a constant, or omitted an obvious hypothesis in a lemma, then I would not bother the editor and referee with it. Minor errors like this should not affect the acceptance of the paper; the referee should have no trouble realizing what you meant (or may overlook it completely). If the paper is accepted, you can include the correction with any other revisions requested by the referee (as before, include a list of all changes). If the paper is rejected, it wouldn't be because of these errors, and you can simply fix them before submitting to a new journal.
You'll have to decide where your corrections fall between these two.