What's the name of this random number generation algorithm?
The algorithm described is an unbiasing algorithm, which is a type of randomness extraction algorithm.
Another method is von Neumann unbiasing where you
can take 2 bits $(X_n,X_{n+1})$ and output $Z=0$ if
$(X_n,X_{n+1})=(0,1),$ output $Z=1,$ if
$(X_n,X_{n+1})=(1,0),$ and discard the two
bits otherwise. This gives exactly uniform
output bits, if the sequence $X_n$ is independent and identically distributed since both the above $(0,1),(1,0)$ have probability exactly $p(1-p)$.