In a piece of music that I'm learning, I'm asked to switch between playing a G# and a B. Although, I'm supposed to play two G#'s that are an octave apart from each other at the same time, same with the B. How do I switch quickly with such a stretch?
Don't try to hold the notes down for the full duration. Let go of the notes and move your whole hand (and arm) sideways to hit the next octave.
Practice playing scales and arpeggios in octaves. Start slowly. Your speed and accuracy will improve with practice. You can also practice "five-finger exercises" in octaves.
At first your hands and arms will soon get tired. When that happens, stop and practice something else. Regular practising (i.e. every day!) will gradually build up your stamina.
Unless you have small hands, you should be able to play octaves fingered either 1-4 (especially on the black keys) or 1-5. Choose the 4s and 5s to make the hand movements easier. I would finger the first two bars of the right hand something like
15 - 14 15 14 14 15 14 | 15 15 15 15 or 14 - 14 15 14 15 15 14 | 15 15 14 15