The answer to your question is affirmative, but the proof turned out to be non-trivial. For instance, I used Baire and Ramsey theorems. Let’s begin.
For each natural $n$ put $X_n=\{x\in (a,b):|f(x)|\le n\}$. We claim that the set $X_n$ is a closed subset of $(a,b)$. Indeed, suppose to the contrary that there exists a point $x\in ((a,b)\cap\overline{X_n})\setminus X_n$. There exists a sequence $\{x_i\}$ of points of $X_n$, converging to $x$. Since a sequence $\{f(x_i)\}$ is bounded, there exists a subsequence $\{x_{i(k)}\}$ of $\{x_i\}$ such that a sequence $\{f(x_{i(k)})\}$ converges to a number $t$. Clearly, $|t|\le n$ and if $t\ne f(x)$ then a pair $\{x_{i(k)}\}$ and $\{x’_k=x\}$ of sequences violates the property, a contradiction.
For each natural $n$ put $X’_n=\operatorname{int} X_n$. By zhw.’s answer, $f$ is continuous on each $X’_n$. Put $X’=\bigcup_n X’_n$. Then $X’$ is a union of a family $\mathcal U$ of its maximal open intervals. Let $U\in\mathcal U$ be any interval and $x\in U$ be any point. Since $U=\bigcup_n U\cap X’_n$, there exists $n$ such that $x\in U\cap X’_n$. It follows that $f$ is continuous at $x$, so $f$ is continuous on $U$ (and on $X’$).
We claim that $f$ is bounded on $U$. Indeed, suppose to the contrary that there exists a sequence $\{x_i\}$ of points of $U$ such that $f(x_{i+1})\ge f(x_i)+1$ for each $i$ (or resp. $f(x_{i+1})\le f(x_i)-1$ for each $i$). By this answer, there exists a monotone subsequence $\{x_{i(k)}\}$ of $\{x_i\}$. For each natural number $l$ let $k$ is the largest number such that $f(x_{i(k)})\le f(x_1)+l$ (resp. $f(x_{i(k)})\ge f(x_1)-l$) and $k’$ be the smallest number such that $f(x_{i(k’)})\ge f(x_1)+l$ (resp. $f(x_{i(k’)})\le f(x_1)-l$). Since the function $f$ is continuous on $U$, by the intermediate value theorem there exists a point $y_l$ in a closed interval between $x_{i(k)}$ and $x_{i(k’)}$, such that $f(y_l)=f(x_1)+l$ (resp. $f(y_l)=f(x_1)-l$). Then $\{y_l\}$ is a Cauchy sequence, because $\lim_{l\to\infty} y_l=\lim_{k\to\infty} x_{i(k)}$ and a pair $\{y_k\}$ and $\{z_k=y_{k+1}\}$ of sequences violates the property, a contradiction.
Put $Y=(a,b)\setminus X’$. If $Y$ is empty then $\mathcal U=\{(a,b)\}$, so $f$ is bounded and, by zhw.’s answer, uniformly continuous.
Suppose to the contrary that $Y$ is non-empty. The topological space $Y$ is a union $\bigcup_n Y\cap X_n$ of a family of its closed subsets. Since $Y$ is a closed subset of a topological space metrizable by a complete metric, it satisfies the condition of Baire theorem. So there exists a number $m$ such that a set $Y\cap X_m$ has non-empty interior in $Y$. That is there exists an interval $(c,d)$ such that $(c,d)\cap Y$ is a non-empty subset of $X_m$. Put $\mathcal U’=\{U\cap (c,d):U\in\mathcal U\}$.
We claim that $(c,d)\subset X_k$ for some natural $k$. Indeed, otherwise we inductively construct an increasing sequence $\{k_n\}$ of natural numbers and a pair $\{x_n\}$ and $\{y_n\}$ of sequences violating the property as follows. Put $k_1=m$. For any $n$, given $k_n$, pick an arbitrary point $z_n\in (c,d)\setminus X_{k_n}$. Since $z_n\not\in X_m$, $z_n\in U’_n$ for some $U’_n\in\mathcal U’$. Then $U’_n=U_n\cap (c,d)$ for some $U_n\in\mathcal U$. By the above, there exists a number $k_{n+1}>k_n$, such that $U_n\subset X_{k_{n+1}}$. Since $(c,d)\not\subset U_n$, the interval $U_n$ (and so the interval $U’_n$ too) has an endpoint $x_n\in (c,d)$. Then $x_n\in Y\cap (c,d)\subset X_m$. Since the function $f$ is continuous on $U’_n\cup \{x_n\}$, by the intermediate value theorem there exists a point $y_n$ belonging to a segment between $x_n$ and $z_n$ such that $|f(x_n)-f(y_n)|=1$. Since $x_n$ is an endpoint of $U’_n$ and $y_n\in U’_n$, we have that $|x_n-y_n|$ is not bigger than the length $|U’_n|$ of the interval $U’_n$. Since for each $n\ge 1$ we have
$z_n\in U_n\setminus X_{k_n}$, whereas $U_p\subset X_{k_{p+1}}\subset X_{k_n}$ for each $1\le p<n$, the intervals $U_n$ are distinct and so, by their maximality, mutually disjoint. Then we have $\sum |U’_n|\le \sum |U_n|\le |(a,b)|=b-a$, so both sequences $\{|U’_n|\}$ and $\{|x_n-y_n|\}$ converge to zero. $\square$