If you express power loss in a power line as $V^2/R$, the $V$ in that expression is the voltage difference between the two ends of the power line, not the voltage difference between the power line and ground.
To supply a fixed amount of power $P_L$ to a load, if the voltage at the load $V_L$ is larger, the current $I=P_L/V_L$ can be smaller. If the power line has a resistance $R$, the voltage across the line is $V_w=IR$, which is smaller for a smaller current. Thus, to supply a fixed amount of power to the load, if the voltage at the load $V_L$ is higher, the voltage drop across the power line $V_w$ is smaller, so the power loss in the power line, $V_w^2/R$, is smaller.
Putting all those pieces together, the power loss in the power line is
$$P_w=\frac{V_w^2}{R}=\frac{(IR)^2}{R}=I^{2}R=\left(\frac{P_L}{V_L}\right)^2 R\ .$$