No, this equality does not hold in general. What is true is that rhs is at most twice as large as lhs and this is sharp. For the sake of brevity I will only show an example where lhs is $1$ and rhs is greater than $1.9$. Choose a very fast growing sequence $a_n \ge 1$. We will construct our function on each interval $I_n = [a_n, a_{n+1}]$ separately. Let $f(x) = \frac{1}{100a_n}$ on $[a_n, 100a_n)$ and $f(x) = \frac{1}{x}$ on $[100a_n, a_{n+1})$ (on $[0, a_1]$ say $f(x) = 1$). Obviously $\limsup xf(x) = 1$ ($f(x) \le \frac{1}{x}$ for $x > a_1$). We have $$\frac{1}{f(a_n)}\int_{a_n}^\infty f(x)^2dx \ge 100a_n(99a_n\frac{1}{10000a_n^2} + \frac{1}{100a_n} - \frac{1}{a_{n+1}}) = 1.99 - \frac{100a_n}{a_{n+1}} \ge 1.9,$$ where in the first inequality we truncated integral at $a_{n+1}$ and the last inequality is true if $a_{n+1} \ge 10^9a_n$. Therefore rhs is at least $1.9$. It is easy to make rhs to be equal to $2$ with the same method. Turns out this is sharp: Again for brevity I will prove that if lhs is less than $1$ then rhs is at most $2$. For big enough $x$ we have $f(x) \le \frac{1}{x}$. Therefore $$\frac{1}{f(x)}\int_x^\infty f(t)^2dt \le \frac{1}{f(x)}(\int_x^{\frac{1}{f(x)}}f(x)^2dt + \int_{\frac{1}{f(x)}}^\infty \frac{1}{t^2}dt) \le \frac{1}{f(x)}(f(x) + f(x)) = 2.$$