We study the contribution of the Higgs amplitude mode on the nonlinear optical response of superconductors beyond the BCS approximation by taking into account the retardation effect in the phonon-mediated attractive interaction. To evaluate the vertex correction in nonlinear optical susceptibilities that contains the effect of collective modes, we propose an efficient scheme which we call the "dotted DMFT" based on the nonequilibrium dynamical mean-field theory (nonequilibrium DMFT) to go around the difficulty of solving the Bethe-Salpeter equation and analytical continuation. The vertex correction is represented by the derivative of the self-energy with respect to the external driving field, which is self-consistently determined by the differentiated ("dotted") DMFT equations. We apply the method to the Holstein model, a prototypical electron-phonon-coupled system, to calculate the susceptibility for the third-harmonic generation including the vertex correction. The results show that, in sharp contrast to the BCS theory, the Higgs mode can contribute to the third-harmonic generation for general polarization of the laser field with an order of magnitude comparable to the contribution from the pair breaking or charge density fluctuations. The physical origin is traced back to the nonlinear resonant light-Higgs coupling, which has been absent in the BCS approximation.