Recover a matrix from an irreducible representation. 
Let $G$ be a finite group and $X: G\rightarrow\text{GL}_3(\mathbb{C})$ be an irreducible $3$-dimensional complex matrix representation of $G$. Suppose that 
  $$
B=\frac{1}{|G|}\sum_{g\in G}X(g)AX(g)^{-1}
$$ 
  where 
  $$
A=\begin{bmatrix}
1&-12&4\\
0&5&3\\
-2& 1&3
\end{bmatrix}.
$$

It is easy to calculate the trace of matrix $B$, that is $\text{Tr}(B)=\text{Tr}(A)=9$. But I don't know how we take advantage of the irreducibility of $X$ and use it to recover the matrix $B$? Any help is appreciated. 

I'm going to switch up the notation a little bit, and treat this with a little more generality. Let $\mathsf{k}$ be an algebraically closed field, with $G$ a finite group such that the characteristic of $\mathsf{k}$  does not divide $\left| G \right|$, and suppose that $\rho : G \to \operatorname{GL}(V)$ is a finite dimensional irreducible representation of $G$ on a representation space $V$, and we suppose also that the characteristic of $\mathsf{k}$ does not divide $\operatorname{dim}_{\mathsf{k}}(V)$. Then for $T \in \operatorname{GL}(V)$, we define $\pi_T \in \operatorname{End}(V)$ by
$$
\pi_T = \frac{1}{\left| G \right|}\sum_{g \in G} \rho(g)T\rho(g^{-1}). 
$$
Then we aim to show that $\rho(h) \circ \pi_T = \pi_T \circ \rho(h)$ for every $h \in G$. Well let $h \in G$, and then
\begin{align*} 
\rho(h) \circ \pi_T & = \frac{1}{\left| G \right|}\sum_{g \in G} \rho(h)\rho(g)T\rho(g^{-1}) \\
& = \frac{1}{\left| G \right|}\sum_{g \in G}\rho(hg)T\rho(g^{-1}) \\
& = \frac{1}{\left| G \right|}\sum_{g' \in G}\rho(g')T\rho(g'^{-1}h) \\
& = \frac{1}{\left| G \right|}\sum_{g' \in G}\rho(g')T\rho(g'^{-1})\rho(h) \\
& = \pi_T \circ  \rho(h).
\end{align*}
Thus $\pi_T$ is an $\mathsf{k}$-linear endomorphism of $V$ commuting with the representation $\rho$. Thus $\pi_T \in \operatorname{Hom}_{\mathsf{k}[G]}(V,V)$, and we call such a map an intertwining operator, and we say that $\pi_T$ intertwines $\rho$. Now, since $\mathsf{k}$ is algebraically closed, and $\rho$ is irreducible, Schur's Lemma states that $\operatorname{Hom}_{\mathsf{k}[G]}(V,V)$ is one-dimensional, and in particular every linear endomorphism of $V$ intertwining $\rho$ is a multiple of the identity map on $V$. Thus $\pi_T$ is a multiple of the identity $\operatorname{Id}_V$ on $V$, $\lambda_T$ say. Moreover, as you observed $\operatorname{trace}(\pi_T) = \operatorname{trace}(T)$. But then
$$
\operatorname{trace}(T) = \operatorname{trace}(\pi_T) = \operatorname{trace}(\lambda_T \operatorname{Id}_V) = \operatorname{dim}_{\mathsf{k}}(V)\lambda_T.
$$
and so $\lambda_T = \frac{\operatorname{trace}(T)}{\operatorname{dim}_{\mathsf{k}}(V)}$. It follows that $\pi_T = \frac{\operatorname{trace}(T)}{\operatorname{dim}_{\mathsf{k}}(V)} \operatorname{Id}_V$.

Now, using this we conclude that in your example, $B$ is $3I_3$ where $I_3$ is the $3 \times 3$ identity matrix.
