To clarify, I mean "conditional expectation" in the sense of $C^*$-algebras (a completely positive projection of norm 1, equivalently, a completely positive linear map onto a $C^*$-subalgebra which is a bimodule map over its image). I'm wondering when this can be homomorphic. The only example I can think of is as follows: if $p$ is a central projection, then $x \mapsto px$ is a homomorphic conditional expectation. (For instance, in a $C^*$-algebra that is a direct sum, projection onto a summand is an instance of this.) Are there others?
Let $A=C[0,1]$, let $B$ be the subalgebra of constant functions, and let $\varphi:A\to B$ be defined by $\varphi(f)=f(0)$. Then $\varphi$ is a $*$-homomorphism (hence completely positive) of norm $1$, satisfies $\varphi(f)=f$ when $f$ is in $B$. Note that $B$ is not a summand of $A$; it is not an ideal. (And the only projections in $A$ are $0$ and $1$.)