If prospective United Kingdom MPs must swear allegiance to the monarch, and if MPs are needed to change laws, how might the UK become a republic, assuming sufficient public support?
Another revolution, obviously. They did that in 1649.
Much more likely, they would politely inform the Queen that the people don't seem to want a Queen any more. If that is really the case, and not just a vocal minority, then after some polite back and forth the Queen would probably step down rather than fighting a civil war which she is unlikely to win.
While many Brits will be true to their oath, consider the difference between the individual monarch, the Crown, and the Crown-in-Parliament (which is a polite way of pretending that the monarch is still involved in legislation).
There is the quip what when it comes to dusty, centuries-old rights and prerogatives, the British monarch gets at most one try at overriding the elected government.
The Oath doesn't preclude republicanism.
(Subject to interpretation, of course.)
Note that the oath (or solemn declaration) only commits the MP to "true allegiance" to the reigning monarch of the day.
I (name of Member) swear by Almighty God that I will be faithful and bear true allegiance to Her Majesty Queen Elizabeth, her heirs and successors, according to law. So help me God.
It doesn't say anything about loyalty to the institution of the monarchy itself. So a republican would argue that they can faithfully take the oath, pay true allegiance to the Queen (or King) and subsequently disband the monarchy. In other words, their loyalty is to the individual, not the institution. They are committing not to undermine the Queen by attempting a coup to replace her with another monarch, not to work with foreign powers against her etc. But they can still disband the monarchy, and say that they've done right by the Queen up until the point where the monarchy no longer exists.
Of course, a monarchist would dispute this reasoning and say that all MPs are honour-bound to support the monarchy in all circumstances. Even if you take this interpretation of the oath, there are republican MPs in parliament so either they are dishonourable or the oath doesn't matter.
There are lots of republican MPs (probably including the Leader of Her Majesty's Loyal Opposition). Some of them have taken the Loyal Oath with their fingers crossed behind their backs.
At the moment, it's not worth campaigning for a republic because polls show that the public is overwhelmingly in favour of the monarchy. That could easily change when the Queen dies. At that point (if enough MPs were republican) they'd just invite the King to step down. If he declined, we would have a constitutional crisis (my guess is that he'd be told his "advisors" had advised him to step down, so he had).
In recent years the constitutional settlement seems to be that significant changes to the constitution require a referendum.
Now even supposing that all MPs took the oath of allegiance entirely literally. There would be no breaking of this oath in legislation to enable a referendum on the abolition of the monarchy. The citizens swear no oath of loyalty and could vote in a referendum to create a monarchy without breaking any oath.
This all assumes a fiction: that the oath of allegiance would prevent MPs from doing anything. In reality, the Crown must do as it is instructed by Parliament. If Parliament says "There is no Monarch" then that is the law, there is no question that a republican Parliament would not act based only on the oath of allegiance. Don't forget that many of the founding fathers of the USA had, at one point or another, sworn allegiance to the King. If the politics require it, the oath is pretty meaningless.
It is not at all clear to me that the oath is intended to be taken literally or that it precludes republican principles. For example, in order to be nationalized as a Canadian citizen one must swear loyalty to the Queen, but the Supreme Court of Canada has held that:
The reference to the Queen is symbolic of our form of government and the unwritten constitutional principle of democracy.
In particular, they explicitly said that it's fine for committed republicans to take this oath.
Of course Canada is not the UK and a citizenship oath is not the same thing as a parliamentary oath, but unless this issue has directly been addressed in the UK, it's entirely plausible that this oath does not, and is not intended to, preclude committed republicans from parliament.
As a side note, it's not actually correct that "prospective United Kingdom MPs must swear allegiance to the monarch". Elected MPs must swear allegiance to the monarch in order to take their seats in Parliament. But they can still be elected as MPs without swearing allegiance.
There's a long history of abstensionism by Irish Republican MPs elected in Northern Ireland who refuse to swear allegiance and don't take their seats in Westminster.
Since o.m.'s answer was apparently always intended to refer to the English Commonwealth, it may be worth keeping the events of the 1688-89 and the "Glorious Revolution" in mind.
In this case, an unpopular Head of State was (relatively bloodlessly) deposed and replaced by another, with the new head(or rather heads) of state and the legislature regularising each other's position in terms of English constitutional law. This somewhat circular argument gives an alternate example of how a British Republic could form without the Monarch's formal assent, and without the all out conflict of the English Civil War.
If there were an impending crisis of succession, and if the reigning monarch himself were to appoint his successors on a republican plan, then the MPs would not be breaking their oaths by supporting that plan.
Oaths can be broken
Oaths can be broken, people sometimes do that. But violating an oath does not invalidate the voting power of the MPs.
If MPs vote to betray the monarch, that vote is valid. They may be considered as oathbreakers and that may have some consequences (for example, they might want to amend the laws on treason while they're at it), but that doesn't change the result, the vote would be binding anyway.