If $f(x)=1$ everywhere then we trivially have the claim. So, suppose $f(\cdot)$ is non-constant. Note that for any prime $p$, there is an $n$ such that $p\nmid f(n)$ (otherwise, there would be a prime $p$ with $p\mid f(n)$ for all $n$, contradicting with the fact that $f(a)$ and $f(b)$ are coprime).
Now, let us construct an increasing sequence $(x_k)_{k=1}^\infty$ of positive integers for which ${\rm gcd}(f(x_k),f(x_\ell))=1$ for any $k\neq \ell$. Set $x_1=a$ and $x_2=b$. Now, let $\mathcal{P}_2=\{p\text{ prime }:\exists i \in\{1,2\}, p\mid f(x_i)\}$. For any prime $p\in \mathcal{P}_2$, let $n_p$ be an integer such that $f(n_p)\not\equiv 0\pmod{p}$. Now, select $x_3\equiv n_p\pmod{p}$ for every $p\in\mathcal{P}_2$ (the existence of such an $x_3$ is well-justified due to Chinese remainder theorem). In particular, assuming $x_1,\dots,x_{n-1}$ is constructed, set $\mathcal{P}_{n-1}$ set of all primes dividing one of $f(x_i)$ with $1\leqslant I\leqslant n-1$. Then, for any $p\in\mathcal{P}_{n-1}$, let $n_p$ be such that $f(n_p)\not\equiv 0\pmod{p}$. Then setting $x_n\equiv n_p\pmod{p}$ for every $p\in\mathcal{P}_{n-1}$ ensures $f(x_n)$ is coprime to all $f(x_1),\dots,f(x_{n-1})$. This completes the argument.