Suppose $(X,\mathcal A,\mu)$ be a compact topological space with a regular Borel measure $\mu$. In particular $\mu$ is a finite measure. Assume $f\in L^1(X)$.Suppose $1\leq p<\infty$ and $D\subset L^p(X)$ is a dense subset. Assume that the map $$T_f:D\rightarrow \mathbb C$$$$h\mapsto \int_Xhfd\mu $$ is a bounded linear functional. Then is $f$ necessarily in $L^{p'}$ where $\frac{1}{p}+\frac{1}{p'}=1$?
I know that $T_f$ extends uniquely to a bounded linear functional $$T_f:L^p(X)\rightarrow \mathbb C$$ So $\exists! \ g\in L^{p'}(X)$ such that $T_f(h)=\displaystyle\int_Xhgd\mu=T_g(h) $
Since $C(X)\hookrightarrow L^p(X)$ is continuous, we get $T_f,T_g\in C(X)^*=\mathcal M(X)$, the space of regular complex Borel measures. The corresponding complex measures are
$$\mu_f(K)=\displaystyle\int_K fd\mu $$
$$\mu_g(K)=\displaystyle\int_K gd\mu $$
But $T_f, T_g$ agree on $C(X)$ and hence $\mu_g=\mu_f$ i.e. for all $K\subset X$, compact $$\int_K fd\mu=\int_K g d\mu $$$$\implies f=g \ \text{a.e.}$$ In particular $f\in L^{p'}(X)$.
I hope this is an okay solution. I would be glad if someone can give an alterbative solution without using complex measures.
I think you can start just assuming $f$ is a measurable function, but you need $D$ to be a dense subspace of $L^p(X)$, closed by restriction to measurable subsets of $X$. In particular, if $h \in D$, then $h \;\sigma(h) \;\sigma(f) \in D$, where, if $g$ is measurable function, $\sigma(g)$ is the sign function of $g$.
The detailed proof is presented below and it does not use complex measure as $C(X)^*$.
Proof:
Given any $h\in L^p(X)$, since $D$ is dense, there is a sequence $\{h_m\}_m$ such that, for all $m$ , $h_m \in D$ and $h_m \rightarrow h$ in $L^p(X)$. Taking a subsequence if needed, we can assume that that $h_m \rightarrow h$ a.e.. So, we have that $h_m f \rightarrow h f$ a.e.
Now, since \begin{align*} T_f:& D\rightarrow \mathbb C\\ &h\mapsto \int_Xhfd\mu \end{align*} is a bounded linear functional and $D$ is a subspace closed by restriction to measurable subsets of $X$, we have, for every $n$, $m$, $(h_n - h_m)\sigma(h_n - h_m) \sigma(f) \in D$ and \begin{align*} \int |h_n f - h_m f| d\mu & = \left | \int |h_n - h_m | |f| d\mu \right| \\ & = \left | \int [(h_n - h_m)\sigma(h_n - h_m) \sigma(f)] f d\mu \right| \\ & \leqslant K \| (h_n - h_m)\sigma(h_n - h_m) \sigma(f) \|_p = K \| h_n - h_m \|_p \end{align*}
So the sequence $\{h_mf\}_m$ is a Cauchy sequence in $L^1(X)$. So there is $k\in L^1(X)$ such that $ h_mf \rightarrow k $ in $L^1(X)$. Taking a subsequence we have $h_{m_i}f \rightarrow k$ a.e.. But we already know that $h_m f \rightarrow h f$ a.e.. So we can conclude that $k=hf$ a.e., $ h_mf \rightarrow hf $ in $L^1(X)$ and $$ T_f(h_m) =\int h_mf d\mu \rightarrow \int hf d\mu $$
We know that $T_f$ extends uniquely to a bounded linear functional $\overline{T}_f$ defined on $L^p(X)$. From what we just proved above, we have \begin{align*} \overline{T}_f:& L^p(X)\rightarrow \mathbb C\\ &h\mapsto \int_Xhfd\mu \end{align*} So $\exists! \ g\in L^{p'}(X)$ such that $\overline{T}_f(h)=\displaystyle\int_Xhgd\mu=T_g(h) $.
So, we have, for all $h \in L^p(X)$, $$ \int_Xhfd\mu = \int_Xhgd\mu <\infty$$ So , for all $h \in L^p(X)$, $ \displaystyle\int_Xh(f-g)d\mu = 0$. So $f=g$ a.e..
Remark: Let us prove the last step in detail. Suppose there is $\varepsilon>0$ such that $\mu([f-g > \varepsilon]) >0 $. Since $\mu$ is a regular Borel measure, there is $K$ compact such that $K\subseteq [f-g > \varepsilon]$ and $0<\mu(K)<\infty$. So $\chi_K \in L^p(X)$ and $$ 0= \int_X \chi_K (f-g)d\mu > \varepsilon \mu(K) >0 $$ Contradiction. So, for all $\varepsilon>0$, $\mu([f-g > \varepsilon]) = 0 $. So $f\leqslant g$ a.e.. In a similar way, considering $\mu([f-g <- \varepsilon]) >0 $, we prove that $g \leqslant h$ a.e.. So $f=g$ a.e..
Remark: Proving the exact form of the extension of $T_f$ is the tricky part of this problem.