Is using two tos next to each other in a sentence ok?
Is using two tos next to each other in a sentence proper English? Like, “They wanted it to go on for as long as it needed to to get them to stop.” Is that right? Or should I put a comma between the tos or something else?
It's grammatically acceptable, but you've chosen an awkward and clumsy way of demonstrating what you mean. If you DO use that sentence, yes, inserting a comma between the two "to"s will make it easier for the reader or listener to understand.
You do not have to correct it as it is perfectly grammatical. In fact the rules of English grammar are the very reason why the two tos occur in the first place. It should also be noted that they are two entirely different tos, each serving a different purpose.
It's correct, and you don't need a comma, but it's a bit clumsy. If this was in casual speech, it's fine, but if it's in writing I'd find another way to say it. I suggest 'as long as necessary to get them to stop'.