Very simply, the photoelectric effect occurs when a photon strikes a surface with enough energy to give to an electron so that it can overcome the forces binding the electron to the surface, that is, the surface’s work function. If energy is leftover this energy becomes the kinetic energy of the released electron.
Since the photon’s energy is used to free the electron from the surface and to give the electron kinetic energy:

The energy of a photon is equal to its frequency multiplied by Planck’s constant (h≈6.63x10-34), or

Therefore, another useful equation is:

Note that below a minimum frequency, the photon will not have enough energy to even free an electron from the surface, therefore for the photoelectric effect to occur, the photon striking the surface must have at least some minimum frequency, called the threshold frequency, which depends on the surface involved.