In solid-state, the work function is the minimum thermodynamic work (i.e. energy) needed to remove an electron from a solid to a point in the vaccum immediately outside the solid surface.
Here "immediately" means that the final electron position is far from the surface on the atomic scale, but still too close to the solid to be influenced by ambient electric fields in the vacuum.
The work function is not a characteristic of a bulk material, but rather a property of the surface of the material (depending on crystal face and contamination).