We discuss the homoclinic bifurcation for a nonlinear inverted pendulum impacting between two rigid walls under external quasiperiodic excitation with two fundamental frequencies. The Melnikov method established for smooth dynamical systems is extended to be applicable to the general quasiperiodic excited impact system. We present a method to compute the first order Melnikov function to derive sufficient conditions under which the perturbed stable and unstable manifolds intersect transversally.