We present an ab initio many-body formalism for computing the frequency-dependent second-harmonic polarizability of semiconductor materials that includes both local-field and excitonic effects. We calculate the second-harmonic polarizability for AlP, AlAs, GaP, and GaAs. In each case, excitonic effects increase the value of the second-harmonic polarizability by about 20%.