$\displaystyle \begin{align*}f(3^0) & = 4 \\ f(3^1) & = 4 + 3(3^1-1) \\ f(3^2) & = 4 + 3(3^1-1) + 3(3^3-1) \\ & = 4 + 3(3^1 + 3^3 - 2) \\ f(3^3) & = 4 + 3(3^1 + 3^3 - 2) + 3(3^5 - 1) \\ & = 4 + 3(3^1 + 3^3 + 3^5 -3)\end{align*}$
In general, it appears that for $\displaystyle k \ge 0$:
$\displaystyle f(3^k) = 4 + 3\sum_{n = 1}^k\left(3^{2n-1}-1\right) = 4 + \dfrac{9}{8}(9^k-1)-3k$