For any $n > 2$, there is no such upper bound. Consider for simplicity the case that $\mathcal{O} = \mathcal{O}_{K}$. If you take $J$ to be the identity class, then $f^{-1}(J)$ is the set of elements of order dividing $n$ in the class group. The question then is - for any $n \geq 2$, is there a uniform bound on the $n$-torsion subgroup of the class group?
Let $\ell$ be a prime dividing $n$ and consider cyclic extensions $K/\mathbb{Q}$ of degree $\ell$. If $K/\mathbb{Q}$ ramifies at $d$ primes, it follows from a Theorem of Hasse that the $\ell$-rank of the class group is $\geq d-1$. (See the theorem referenced on the bottom of page 86 of the paper "On the 3-class groups of cyclic cubic extensions of certain number fields", which can be found here.) It is not hard to show that there are cyclic extensions that ramify at arbitrarily many primes. (If $p_{1}$, $\ldots$, $p_{k}$ are primes $\equiv 1 \pmod{\ell}$, for each $i$, $1 \leq i \leq k$ we choose $H_{i}$ to be the unique subgroup of $(\mathbb{Z}/p_{i} \mathbb{Z})^{\times}$ of index $\ell$, and for each $i$, let $\chi_{i} : (\mathbb{Z}/p_{i}\mathbb{Z})^{\times} \to \mathbb{C}^{\times}$ be a character for which $\ker \chi_{i} = H_{i}$. Now, define $H = \{ x \in (\mathbb{Z}/n\mathbb{Z})^{\times} : \prod_{i} \chi_{i}(x) = 1 \}$. This $H$ has index $\ell$ in $(\mathbb{Z}/n\mathbb{Z})^{\times}$. Using the isomorphism $Gal(\mathbb{Q}(\zeta_{n})/\mathbb{Q}) \cong (\mathbb{Z}/n\mathbb{Z})^{\times}$, we get that $H$ corresponds to a subfield of $K$ of $\mathbb{Q}(\zeta_{n})$, and the conductor-discriminant formula implies that $K$ ramifies at all primes dividing $n$.)
This constructs an $\ell$-extension $K$ where the $\ell$-torsion in the class group can be arbitrarily large. If now $L/K$ is a totally ramified degree $n/\ell$ extension, then the class group of $L$ has the class group $K$ as a quotient (by class field theory). It follows that $L$ is a degree $n$ number field, and the $n$-torsion in the class group of $\mathcal{O}_{L}$ can be as large as you like.