There are two interpretations: (i) The $n$ objects are distinct and (ii) They are identical.
(i) Let the colours be $A,B,C$. A colouring can be viewed as a function from the set $\{a_1,a_2,\dots,a_n\}$ to the set $\{A,B,C\}$. There are $3^n$ such functions.
However, some ,do not use all the colours: There are $2^n$ that do not use $A$, $2^n$ that do not use $B$, and $2^n$ that do not use $C$.
However, $2^n+2^n+2^n$ does not count correctly the forbidden colourings. For in the first $2^n$, the colourings that use neither $A$ nor $B$ are counted. They are also counted in the second $2^n$. The colourings that use neither $A$ nor $C$ are counted in the first $2^n$ and the third. And the colourings that use neither $B$ nor $C$ are also double-counted. So the number of forbidden colourings is $3\cdot 2^n$ minus the number of monochromatic colourings, which is $3$. There are $3\cdot 2^n-3$ forbidden colourings.
Thus the number of colourings in which every colour is used at least once is $3^n -3\cdot 2^n+3$.
(ii) Line up the $n$ identical objects. There are $n-1$ "gaps" between consecutive objects. Choose $2$ of these gaps to put a separator into, colour everything up to the first separator $A$, colour the objects between the two separators $B$, and the rest $C$. There are just as many allowed colourings of the identical objects as there are ways to insert separators. There are $\binom{n-1}{2}$ such ways.
Remark: The calculation for distinct objects used the Principle of Inclusion/Exclusion. The calculation for identical objects used the technique of Stars and Bars.