6. D.

Let $g(x)=f(x)-x^{3}=a x^{2}+b x+c$.
From $f(a)=a^{3}, f(b)=b^{3}$
$$
\Rightarrow g(a)=g(b)=0 \text {. }
$$

Then $a, b$ are the two roots of the equation $g(x)=0$
$$
\begin{array}{l}
\Rightarrow a+b=-\frac{b}{a}, a b=\frac{c}{a} \\
\Rightarrow c=-\frac{a^{4}}{a+1}=-(a^{2}+1)(a-1)-\frac{1}{a+1} .
\end{array}
$$

Since $c$ is an integer, we have $a+1= \pm 1 \Rightarrow a=0$ (discard) or -2. Therefore, $c=16$.
6. Let the function $f(x)=x^{3}+a x^{2}+b x+c$ (where $a$, $b$, and $c$ are all non-zero integers). If $f(a)=a^{3}$ and $f(b)=b^{3}$, then the value of $c$ is ( ).
(A) -16
(B) -4
(C) 4
(D) 16