The work function (wf) is the least amount of energy required to remove an electron from the surface of a conducting material, to a point just outside the metal with zero kinetic energy.
As the electron has to move through the surface region, it’s energy is influenced by the optical, electric and mechanical characteristics of the region.
Hence, wf is an extremely sensitive indicator of surface condition and is affected by absorbed or evaporated layers, surface reconstruction, surface charging, oxide layer imperfections, surface and bulk contamination, etc.