The photoelectric effect is the emission of electrons from the surface of a metal due to exposure of electromagnetic radiation above a certain frequency.
Photon energy (E=hf or E=hc/λ).
The work function is the minimum energy needed by a conduction electron to escape from the metal surface when the metal is at zero potential.
When a conduction electron absorbs a photon, its kinetic energy increases by an amount equal to the energy of the photon. If the energy of the photon exceeds the work function, the conduction electron can leave the metal.
If the conduction electron doesn’t leave the metal, it repeatedly collides with other electrons and positive ions and loses its extra kinetic energy