The answer is $\frac{(a+b)^2}{4ab}$ by taking $X$ half probability $a$ and half probability $b$.
We sample $X_1,X_2,\dots,X_n$ i.i.d. with $X$. Let $Y=\frac{1}{n^2}(\sum_{i=1}^n X)(\sum_{i=1}^n 1/X)$. Let $n\to\infty$ so we can get $Y\to \mathbb{E}(X)\mathbb{E}(1/X)$ in probability. Now we prove that $Y\le \frac{(a+b)^2}{4ab}$ always holds, and this can yield the desired result because of the convergence. Without loss of generality, we assume that $n$ is even.
Now we fix $X_2,\dots,X_n$ and make $X_1$ variable. We can write
$$Y=(\sum_{i=1}^n X_i)(\sum_{i=1}^n 1/X_i)=AX_1+B/X_1+C$$
Where $A,B,C$ are expressions of other variables ($X_2,\dots, X_n$). This takes the maximum when $X_1$ hits the wall, that is, $X_1$ is either $a$ or $b$. So, we merge $x$ into one of $u$ $a$'s or $v$ $b$'s. Now, all of them are $a$ or $b$, and assume $u$ and $v$ are number of $a$ and $b$ again. So, we have
$$Y=\frac{1}{n^2}(\sum_{i=1}^n X)(\sum_{i=1}^n 1/X)=\frac{1}{n^2}(ua+vb)(\frac ua+\frac vb)=\frac{1}{n^2}(u^2+v^2+uv(a/b+b/a))=1+\frac{uv}{n^2}(a/b+b/a-2)$$
Here, $uv$ is maximized when $u=v=n/2$. So we have
$$Y=1+\frac{uv}{n^2}(a/b+b/a-2)\le 1+\frac{(n/2)^2}{n^2}(a/b+b/a-2)=1+\frac{a^2+b^2-2ab}{4}=\frac{(a+b)^2}4$$