There will be a pop up icon on your infirmary and when you go their you will see units that can be restored for free (it will be on the left side of infirmary)
It happens automatically, it restores units only that were killed while defending your haven