What properties does a distribution (in the generalized function sense) has to have in order to be a function. That is, when is $T(\varphi) = \int f \varphi$ for some $f$?

First of all, $T$ must have order zero, i.e., $T(\varphi)\le C(K)\sup\varphi$ for any test function $\varphi$ supported on a compact set $K$. By Riesz representation theorem, $T$ is a measure. To be a locally integrable function, it must be absolutely continuous with respect to the Lebesgue measure. One way to express this condition: $C(K)\to 0$ as the Lebesgue measure of $K$ tends to zero, which $K$ staying within a fixed compact set. 


I haven't thought about this carefully enough, but it seems that there is some ambiguity in your question about what the integral $\int f\varphi$ is supposed to mean. As Ryan and Leonid have said: if you want the representing function $f$ to be locally integrable then the RadonNikodym theorem is what you need. On the other hand, if you allow principalvalue integrals (which is probably not what you want, I'm guessing, but I wasn't sure from your question) then I think $$ \varphi \mapsto \int_{\rm p.v.} \frac{\varphi(t)}{t}\ dt $$ would be a tempered distribution that is in some sense `represented by a function', even though the function is not everywhere locally integrable. 


Assuming that the question is to be understood in the sense of when a distribution is represented by a locally integrable function, here is a characterisation which is perhaps more applicable than the solution already given: for each compact $K$ and each sequence $(\phi_n)$ of test functions with support in $K$ which are uniformly bounded and converge in the $L^1$norm to zero, $T(\phi_n) \to 0$. This is because there is a nice, complete topology on $L^\infty(K)$ for which the test functions are dense, the dual is $L^1$ and the convergence is as above. There are several explicit descriptions of this topologyas a strict topoogy, as a mixed topology or as the Mackey topology for the duality $(L^\infty,L^1)$ (see the book "Saks Spaces and Applications to Functional Analysis"). 

