If $f$ is measurable and $fg$ is in $L^1$ for all $g \in L^q$, must $f \in L^p$?
So that $L^p$ and $L^q$ are duals of each other, let $1\lt p,q\lt\infty$, as well as $\frac1p+\frac1q=1$.
Furthermore, so that we can apply the Riesz Representation Theorem, we should assume that we are working in a measure space where the measure is countably additive on a regular, locally compact Hausdorf space.
Without these conditions, the counterexample given by Danny Pak-Keung Chan and David C. Ullrich in Danny's answer shows that the answer is no.
Suppose that $fg\in L^1$, but there is no $C$ so that $\|fg\|_{L^1}\le C\|g\|_{L^q}$. Without loss of generality, we can assume all functions are positive. Suppose we have a sequence of $L^q$ functions $\{g_k:\|g_k\|_{L^q}=1\}$ where $\int|fg_k|\;\mathrm{d}x>3^k$. Set $g=\sum\limits_{k=1}^\infty2^{-k}g_k$. $\|g\|_{L^q}\le1$ yet $fg\not\in L^1$. Thus, there must be a $C$ so that $\|fg\|_{L^1}\le C\|g\|_{L^q}$. Then, as you say, apply the Riesz Representation Theorem.
I would like to add another answer to this question. Consider the linear functional $T:L^q\to\mathbb{C}$ defined by $$Tg=\int gf.$$
It is sufficient to prove that $T$ is bounded. To this end, assume that $g_n\in L^q$ is such that $\|g_n\|_q\to 0$.
We can extract a subsequence of $g_n$ (not relabeled) such that $$g_n(x)\to 0,\ |g_n(x)|\le h(x),\ \mbox{a.e.},\tag{1}$$
where $h\in L^q$ (this partial converse of Lebesgue theorem, can be found, for example, in Rudin's book "Real and Complex Analysis", Theorem 3.12, or in Brezis book "Functional Analysis", Theorem 4.9). It follows from $(1)$ that $$g_n(x)f(x)\to 0,\ |g_n(x) f(x)|\leq h(x)|f(x)|,\ \mbox{a.e}.\tag{2}$$ Note that by hypothesis, $h|f|\in L^1$, therefore, we can apply Lebesgue theorem to conclude that $$Tg_n\to 0.\tag{3}$$
As every subsequence of $g_n$, has a subsequence which satisfies $(1)$, we conclude that $(3)$ is true for the whole sequence.
Oops. Someone asked me a question in a comment to this answer. So I sort of assumed it was an Answer from me, and replied to the comment with an edit. Oops, no it's an Answer from someone else. Sorry, didn't mean to revise his post. Although I didn't change anything, just added more content, so I'm tentatively leaving this as it is.
Original Answer
The answer is NO. All the proofs presented in above are invalid. Counter-example: Consider the measure space $(X,\mathcal{M},\mu)$, where $X=\{x_0\}$, $\mathcal{M}= \{\emptyset,X\}$, and $\mu(\emptyset)=0$, $\mu(X)=\infty$. Let $p,q\in(1,\infty)$ be such that $\frac{1}{p}+\frac{1}{q}=1$. In this case, $L^q=\{0\}$. Therefore, if we define $f:X\rightarrow\mathbb{R}$ by $f(x_0)=1$, then $fg\in L^1$ for all $g\in L^q$. However, $f\notin L^p$.
(Third-party) Edit
Just now I've been asked what's the problem with the accepted answer. It seems maybe worthwhile explaining, since it's actually a bit more subtle than I realized at first.
With apologies lest I misrepresent what someone had in mind; nobody included details for the wrong part, so to explain where the error is I have to start by inserting my own version of the details:
So assume that $fg\in L^1$ for all $g\in L^p$. Just to give a name to what we've correctly proved above:
Lemma. $||fg||_1\le C||g||_p$.
At this point everyone says that the lemma plus RRT imply $f\in L^p$. The wrong argument is this: Define $\Lambda g=\int fg$. Then $\Lambda\in (L^q)^*$. But RRT says $(L^q)^*=L^p$, hence $f\in L^p$.
The problem arises only at the very last step. At first I assumed the problem was with $(L^q)^*=L^p$ if the measure is not $\sigma$-finite, but that's not quite it:
Assume in addition that $1<p<\infty$. Then it is true that $(L^q)^*=L^p$ for any measure. But that doesn't show $f\in L^p$. Again we need to insert details: RRT does show that there exists a unique $F\in L^p$ with $\int Fg=\int fg$ for all $g\in L^q$. And now
Error. If $\int Fg=\int fg$ for all $g\in L^q$ then $f=F$ almost everywhere.
That's easy in the $\sigma$-finite case, but as we see in the example at the top, in general there need not be enough $L^q$ functions to separate points of $L^p$.