I believe I have a solution.

First direction : If there exists such $h$ we define $g(x,y) = e^{2\pi i (h(x)-my)}$

This is a measurable map and $Tg(x,y) = e^{2\pi i (h(x+a)+my-mf(x))}$ now $mf(x)=h(x+a)-h(x)$ so we have $Tg(x,y) = e^{2\pi i (h(x)-my)} = g(x,y)$ which is contradiction to ergodicity. (Hence ergodicity implies there is no such $h$).

Second direction: Suppose there is no such $h$, we show that $T$ is ergodic. Suppose by contradiction it is not, then there exists an invariant function $g(x,y)=\sum_{m} a_m(x) e^{-2\pi i m y}$ applying $T$ we have $Tg(x,y) = \sum_m a_m(x+a) e^{-2\pi i m f(x)} e^{-2\pi i m y}$

Since the Fourier coefficients unique we have $a_m(x)=a_m(x+a)e^{-2\pi i m f(x)}$, in particular $|a_m(x)| = |a_m(x+a)|$ as $a$ is irrational we have that $|a_m(x)|$ is a constant and we can assume it is equal $1$ for $m$ such that $a_m(x)\not = 0$.

Choose $m\not= 0$ such that $a_m(x)\not = 0$ (which exists, otherwise $g$ is a constant), and let $b_m(x)$ be such that $a_m(x) = e^{2\pi i b_m(x)}$ we conclude that $mf(x)=b_m(x+a)-b_m(x) \text{ mod 1}$ which is a contradiction.