You're on the right track here. I'm going to use a bit of different notation, because "initial" and "final" aren't unique if you're breaking the path up into two segments like you are. So let's define the following:
- Point A: release point for the pendulum, with the string horizontal
- Point B: bottom of the swing
- Point C: top of the swing, after the string has wrapped around the peg
Your first step was to calculate the velocity at the bottom of the swing, i.e., point B. Your derivation for this was completely correct; I've just copied it over below with the new notation, using "A" and "B" instead of initial and final:
\begin{aligned}
K_A + U_{gA} &= K_B + U_{gB}\\
0 + U_{gA} &= K_B + 0\\
U_{gA} &= K_B\\
mgL &= \frac{1}{2}mv_B^2\\
L &= \frac{v_B^2}{2g}
\end{aligned}
For the subsequent trip up (from point "B" to point "C"), you have to be a little more careful. The final height of the bob will not be $h$, but will instead be $2(L - h)$; this is because the bob is swinging in a circle of radius $(L- h)$ now. So you have
\begin{aligned}
K_B + U_{gB} &= K_C + U_{gC}\\
K_B + 0 &= K_C + U_{gC}\\
\frac{1}{2}mv_B^2 &= \frac{1}{2}mv_C^2 + mg(2(l-h))\\
2(L - h) &= (v_B^2-v_C^2)/2g
\end{aligned}
You already found the relationship between $v_B^2$ and $L$ in the previous set of equations, though; so you can just plug that in to get
$$
2L - 2 h = L - \frac{v_C^2}{2g}.
$$
The last piece you'll need is to figure out what $v_C$ needs to be in order for the tension to go to zero at the top of the loop. I would be very surprised if you hadn't done this question already, either in your textbook or on a homework assignment, so you might want to go back and take a look at that. But if not, here's how to get started on it: The bob is moving in a circle, so the net force on it must be acting inwards and have a particular magnitude. Now, what forces are be acting on the bob at this point in time? Which directions do they have?
As an aside: we didn't really have to break up the pendulum's trip into two segments this way; I did it because you seemed to be thinking about it that way. But it would be equally valid to treat Point A as the "initial" position, Point C as the "final" position, and ignore Point B altogether.
delete
link at its bottom. $\endgroup$