I am a masters student and recently I got a paper of mine published in a journal. The paper contains my name and another authors name that helped me with some minor things. I didn't know that this paper was going to be published but after it did I told my professor about it and he said that the paper could be part of my thesis. The problem is that for that to happen the paper has to only include my name and my professors name. After telling the second author about this he said that he doesn't mind if his name is replaced with my professor's. Can I ask the journal to do this during page proofs or is it too late?
This would be up to you, your colleague, the professor and the editorial rules of the journal - if you decide to go down that path, read up on the rules or ask the editorial team.
However, @polfosol makes a very important point in his comment, that to do this would potentially be unethical, primarily due to your co-author contributed directly towards the paper, your professor did not (I assume based on your question). A major consideration is that this publication also adds to your current co-author's research profile, not just yours.
A possible solution to this is to write another paper, building on and citing the research in this published paper.
Another possible solution is for your professor to contribute to reviewing the proofs and having him added as another co-author - once again, if you decide on this, then you must check to see if it is alright with the journal (but this may also be stretching ethics a bit).
I don't understand why for your paper to be included in your thesis, it should be co-authors only by you and your advisor. I have not heard of any such demands for any PhD thesis, or any thesis, seems unethical. But do not worry, even if you can not include this in your thesis, it is your paper and counts more than a thesis for PhD applications or any application if you want to go to industry, and so on. Regarding the author changes, it may or may not be possible. I know one professor who have changed the name of the authors at the final stage of publication, which lead to a very confusing paper. The journal staff have used the first version of authors for the manuscript when index by ISI web of knowledge. So when searching in databases for this paper the authors list includes the first version of the authors, while in the online version of the paper from the journal web page the authors are listed as the final list of authors. The best option would be to ask the journal editors. However, if you are planning to do this, read carefully the publication ethics of the journal. Also, you can ask for another opinion of another professor at your university. Finally, congratulations for your accepted paper!