That principle of persistence relies on the identity theorem: If two holomorphic functions $f,g:U\to \mathbb{C}$ (where $U\subseteq\mathbb{C}$ is an open connected subset of $\mathbb{C}$) have the same values on a set $T\subseteq U$ which has a limit point in $U$, then they are equal everywhere in $U$.
In particular, if $U$ contains a non-trivial interval of $\mathbb{R}$, the theorem can be applied. In the simplest case, the argument becomes: If $f,g$ are entire functions in $\mathbb{C}$ so that the equation $f(z) = g(z)$ holds for all $z\in\mathbb{R}$, then it holds for all $z\in \mathbb{C}$. Your first example is of this type.
For your second example, note that the scalar product is defined differently for real and complex vector spaces, although the restriction of a scalar product on complex numbers to the reals is still a scalar product on the reals.
Defining $f:\mathbb{C}^2\to \mathbb{C}$ and $g:\mathbb{C}^2\to\mathbb{C}$ by $f(u,v) = u \bar v$ and $g(u,v) = uv$,
we have $f|_{\mathbb{R}^2} = g|_{\mathbb{R}^2}$, but not $f = g$. This is a good example showing that the mentioned identity principle doesn't extend to functions of more than one complex variable.
edit: And also, the complex conjugation is not a holomorphic function!