I suppose the missing elements of the setup of your question are as I inferred in my comment to the OP. If so, then any orthonormal basis will have your desired property for a sufficiently large $N\in\mathbb{N}$ depending on $f$. If you want $N$ to be independent of $f$ (which I assume from now on to be what the OP means by a "compact" orthonormal basis) this is only possible if the function space in question is finite dimensional, in which case once more every orthonormal basis is compact. Unfortunately, that makes the concept of a compact orthonormal basis trivial in finite dimensions and void in infinite dimensions. I still believe, though, that the question has pedagogical value (so I upvoted it) because it illustrates an inherent difficulty in making finite dimensional approximations in an infinite dimensional function space which may be relevant in practical applications.
To reach that conclusion, it is more useful to formulate this problem abstractly: let $F$ be a (real or complex) pre-Hilbert space whose scalar product is denoted by $\langle\cdot,\cdot\rangle$ (which we assume to be antilinear in the first variable and linear in the second if $F$ is complex), whose associated norm is denoted by $\|f\|=\sqrt{\langle f,f\rangle}$, $f\in F$. Let $S=\{u_i\ |\ i\in\mathbb{N}\}$ be an orthonormal basis of $F$, that is, $S$ is an orthonormal set in $F$ (i.e. $\langle u_i,u_j\rangle=1$ if $i=j$ and $0$ if $i\neq j$) that is also a topological basis of $F$, that is, for any $f\in F$ there is a unique sequence $(\alpha_i)_{i\in\mathbb{N}}$ of (real or complex) scalars such that $$f=\sum^\infty_{i=1}\alpha_i u_i\ ,$$ with convergence in the (above) norm of $F$. Notice that the countability of $S$ implies that the linear topology of $F$ induced by $\langle\cdot,\cdot\rangle$ is separable. Continuity of the linear functionals $\langle u_i,\cdot\rangle$ then entail that $\alpha_i=\langle u_i,f\rangle$ for all $i\in\mathbb{N}$. Moreover, one then has the Bessel inequality $$\sum_{i\in I}|\langle u_i,f\rangle|^2\leq\|f\|^2$$ for all $I\subset\mathbb{N}$, which allows us to set $C=1$ for all $N\in\mathbb{N}$. Set $P_N f=\sum^N_{i=1}\langle u_i,f\rangle u_i$, $N\in\mathbb{N}$ fixed, so that the sequence $(P_n f)_{n\in\mathbb{N}}$ converges to $f$ in $F$ for all $f\in F$. That convergence for $\frac{1}{\|f\|}f$, $0\neq f\in F$ entails that for all $\epsilon>0$ there is $N_\epsilon\in\mathbb{N}$ such that $$\|f\|^2-\|P_N f\|^2=\|f-P_N f\|^2=\sum^\infty_{i=N+1}|\langle u_i,f\rangle|^2\leq\epsilon^2\|f\|^2$$ for all $N\in\mathbb{N}$ with $N\geq N_\epsilon$. Setting $\epsilon<1$ so that $0<c=1-\epsilon^2<1=C$ yields $$c\|f\|^2\leq\|P_N f\|^2=\sum^N_{i=1}|\langle u_i,f\rangle|^2\leq\|f\|^2$$ (the case $f=0$ is trivially included with equality), where the last inequality is just Bessel's inequality for $I=\{1,\ldots,N\}$.
If you want the stronger property of compactness from the above chosen orthonormal basis $S$, that is, the last chain of inequalities above holding with $N$ independent of $f$, it suffices that this holds for such an $N$ and all $f$ in the unit sphere $K=\{f\in F\ |\ \|f\|=1\}$. If $F$ is finite dimensional, this is automatically true for every orthonormal basis of $F$ since then $K$ is compact. If we asssume that $F$ is infinite dimensional, this amounts to the sequence of finite rank linear operators $(P_n)_{n\in\mathbb{N}}$ converging to the identity in the operator norm topology, which on its turn implies that the identity is a compact linear operator. This implies that the closed balls of $F$ are compact, which can only happen if $F$ is finite dimensional, a contradiction.