Control of non-Markovian effects in the dynamics of polaritons in semiconductor microcavities