Ionization energy is the amount of energy required to remove the electron that is most loosely bound of an isolated gaseous atom to form a cation.
Electron affinity is the amount of energy released when an electron is added to a neutral atom or a molecule in a gaseous state to form negation ion.
The difference of ionization energy and electron affinity is ionization energy is the required energy to remove an electron from a neutral atom. Whereas, electron affinity is the energy change when a neutral atom attracts an electron to become a negative ion.