Where stars form and live at high redshift: clues from the infrared