So for a hydrogen atom, an electron at n=1 would require 13.6eV of energy to be excited to the infinite energy level, so thats ionization. Is the work function the energy to overcome the attraction between the ionized electron and the nucleus?
The work function energy is the minimum energy that an electron need to escape from inside the surface of solid to outside the surface of a solid, the solid being made up of many atoms .
The ionisation energy is the energy that an electron (usually the most loosely bound) needs to escape from the (one) atom completely.
When were talking about the work function, we're usually referring to the surface of a metal, say, Sodium! So the work function would be the minimum energy required to remove an electron from the surface of Sodium. This minimum energy is the energy required for just removing an electron. The electron emitted has 0 kinetic energy.
Think of it this way. This is the energy required by an electron to escape the metal lattice. Whenever atoms of an element combine to form a compound (or lattice), the properties of their electrons is different from what it is in the element's individual atom. The electron in a sodium atom is its own, while in a sodium metal lattice, the electron isn't its own anymore. It is attracted by the other atoms and also repelled by the electrons of the other atoms. In other words its energy changes. That's why the ionisation energy is different from the work function of a metal.
The difference between work function and ionisation energy lies in their definition.
Ionisation energy is the energy required to remove an electron (first ionisation energy is the energy required to remove the outermost electron, second ionisation energy is the energy is the energy required to remove the next and so on so forth) from an isolated, gaseous atom of an element.
The difference is one concerns the surface of the substance while the other concerns an atom of the substance in the gaseous phase.
Generally the work function is defined for a crystalline solid with a band structure, like a metal. The work function is the energy required to extract an electron from the conduction band to the vacuum. The ionization energy is the energy required to extract an electron from a neutral atom in a gas. As you can see the two concepts are similar but in a different context.