A counterexample to this problem can be constructed as follows. Take a sequence $(K_n)_{n\in\omega}$ of pairwise disjoint nowhere dense compact sets $K_n\subset[0,1]$ of positive Lebesgue measure $\lambda(K_n)>0$ such that $\sum_{n=0}^\infty\lambda(K_n)=1$. Consider the function $f:[0,1]\to [0,1]$ defined by $$ f(x)=\begin{cases}\frac1{2^n}&\mbox{if $x\in K_n$ for some $n\in\omega$;}\\ 0&\mbox{otherwise}. \end{cases} $$
It is easy to see that the function $f$ is not continuous a.e.
On the other hand, for every $\varepsilon >0$, we can choose $n\in\mathbb N$ so large that $\frac1{2^n}<\varepsilon$ and $\sum_{i>n}\lambda(K_i)<\varepsilon$. Then the set $H=[0,1]\setminus \bigcup_{i\le n}K_i$ has measure $\lambda(H)<\varepsilon$ and the restriction $f{\restriction}H$$f$ has oscillation $\le \frac1{2^n}<\varepsilon$ at points of the open set $H$ (because $f(H)\subset [0,\frac1{2^n}]$).