When commutative ring hom $A\to A/I$ flat?

Since $R/I$ is finitely generated over $R$, it's flat if and only if it's projective. We can then use this answer from Mathoverflow to deduce that $I$ is principal generated by an idempotent.

Edit: This requires an assumption that $R$ is noetherian, or that $R/I$ is finitely presented,