Proof by induction on $n$:
$$\begin{eqnarray}
f(p^{n+1}-1)=\\
f((p-1)(1+p+p^2+ \cdots p^{n-1}+p^n))=\\
f((p-1)+(p-1)p+(p-1)p^2+ \cdots (p-1) p^{n-1} + (p-1)p^n)=\\
((p-1)+(p-1)p+(p-1)p^2+ \cdots (p-1) p^{n-1} + (p-1)p^n)
+ f( \lfloor \frac{p-1}{p} + (p-1)+(p-1)p+(p-1)p^2+ \cdots (p-1)p^{n-1} \rfloor)=\\
p^{n+1}-1 + f( (p-1)+(p-1)p+(p-1)p^2+ \cdots (p-1)p^{n-1})=\\
p^{n+1} + p^{n} + \cdots + 1 -(n+2)=\\
\frac{p^{n+2}-1}{p-1} -n-2
\end{eqnarray}$$
Proof by induction on $n$:
$$0 \le a_i \lt p , \forall i: \;0 \le i \le n$$
$$\begin{eqnarray}
f(a_0+a_1p+a_2p^2+ \cdots a_{n-1} p^{n-1} + a_n p^n) = \\
(0 \; \text{if} \; a_0=0, \; \text{otherwise} \; a_0+a_1 p+a_2p^2+ \cdots a_{n-1} p^{n-1} + a_n p^n) + \\f( \lfloor \frac{a_0}{p}+a_1+a_2p+ \cdots a_{n-1} p^{n-2} + a_n p^{n-1} \rfloor) \\
\le
((p-1)+(p-1)p+(p-1)p^2+ \cdots (p-1) p^{n-1} + (p-1)p^n) \\
+f( \lfloor \frac{p-1}{p} + (p-1)+(p-1)p+(p-1)p^2+ \cdots (p-1)p^{n-1} \rfloor) =\\
f((p-1)+(p-1)p+(p-1)p^2+ \cdots (p-1) p^{n-1} + (p-1)p^n)= \\
f((p-1)(1+p+p^2+ \cdots p^{n-1}+p^n))=\\
f(p^{n+1}-1)
\end{eqnarray}$$
So the maximum on $\{0,\cdots , p^n\}$ is $f(p^n-1)= \frac{p^{n+1}-1}{p-1} -n-1$