Lemma : Lebesgue number
Let $(X,d)$ a compact metric space and $(U_j)_{j\in J}$ an open cover of $X$.
It exists $\lambda>0$ such as $\forall x\in X$, $\exists j_0\in J$, $B(x,\lambda)\subset U_{j_0}$.
We call $\lambda$ the Lebesgue number of the open cover.
Proof : by reductio ad absurdum, suppose that this statement is false.
Then $\forall n\in\mathbb N^*$, it exists $x_n$ such as $B(x_n,\frac{1}{n})$ isn't in any $U_j$.
By compactness, it exists a subsequence $(x_{\varphi(n)})_n$ which converges to $x\in X$.
Let $j_0\in J$ such as $x\in U_{j_0}$. Let $\varepsilon>0$ such as $B(x,\varepsilon)\subset U_{j_0}$, then, after a certain rank, $B(x_{\varphi(n)},\frac{1}{\varphi(n)})\subset B(x,\varepsilon)\subset U_{j_0}$ and so you get a contradiction.
(First, it exists $N_0$ such as $n\ge N_0\Rightarrow\frac{1}{\varphi(n)}<\frac{\varepsilon}{2}$, next, it exists $N_1$ such as $n\ge N_1\Rightarrow\|x-x_{\varphi(n)}\|<\frac{\varepsilon}{2}$. Let $N=\max(N_0,N_1)$ and then for $n\ge N$, let $y\in B(x_{\varphi(n)},\frac{1}{\varphi(n)})$, then $\|x-y\|\le\|x-x_{\varphi(n)}\|+\|x_{\varphi(n)}-y\|\le\varepsilon$). $\blacksquare$
Your result :
By continuity, $f^{-1}(I_n)$ is an open set. Now, $f^{-1}(I_n)$ is an open cover of $K$ (Let $x \in K$, then $f(x)\in f(K)$, so it exists $n$ such as $f(x)\in I_n$ and finally $x\in f^{-1}(I_n)$), and let $\delta$ its Lebesgue number. You have your result : $\forall x\in K$, it exists $n\in\mathbb N$, such as $(x-\delta,x+\delta)\subset f^{-1}(I_n)$.