The task that you describe in your question — a circuit which flips a single qubit, if and only if the two input states are different — is not possible. We can show this as follows.
First, there is no way to distinguish two states which differ only by a global phase, because no quantum operations can distinguish between two state-vectors which only differ in a global phase. (In fact, for two such states as input, there is no real way to describe which of the two states has that phase: the global phase applies to the total state, including all tensor factors.)
Setting that aside, however, there is a more significant obstacle: the linearity of quantum mechanics.
Suppose that you had a unitary circuit $U$, which performed the following transformation for inputs $\lvert x \rangle$ and $\lvert y \rangle$ in the states $\lvert 0 \rangle$ and $\lvert 1 \rangle$:
$$\begin{align}
\lvert 0 \rangle \;\lvert x \rangle\; \lvert y \rangle\; \lvert \text{work space} \rangle
\;\mapsto\;
\lvert \delta_{x,y} \rangle \;\lvert \psi_{x,y} \rangle,
\end{align}$$
where $\delta_{x,y}$ is the Kronecker delta, "$\text{work space}$" is some fixed initial state of auxiliary qubits provided as work space, and $\lvert \psi_{x,y} \rangle$ is some (possibly complicated) quantum state that depends on $x$ and $y$.
We take the first qubit to be the answer qubit.
Note that the states $\lvert \psi_{x,y} \rangle$ will be orthogonal to one another for different values of $x$ and $y$. Then, what happens if we introduce a state which is not in the standard basis?
$$ \lvert 0 \rangle \; \lvert 1 \rangle \; \lvert + \rangle \; \lvert \text{work space} \rangle \mapsto
\tfrac{1}{\sqrt 2} \Bigl(
\lvert 0 \rangle \; \lvert \psi_{1,0} \rangle \;+\; \lvert 1 \rangle \; \lvert \psi_{1,1} \rangle
\Bigr) $$
so that the answer qubit is entangled (and in fact maximally entangled) with the rest of the qubits. In particular, it does not give you $\lvert 0 \rangle$, which is what you wanted for your procedure.
As @MicheleAmoretti and @MarkusHeinrich indicate, the best that you can do is to use the controlled-SWAP test, which will succeed with probability 1/2 if the two input states are orthogonal, and which will have a worse and worse success probability (as a means of distinguishing distinct states) for distinct states which have larger and larger fidelities.