Controlling coherent and incoherent spin dynamics by steering the photoinduced energy flow