He has to resign as PM, otherwise HMQ could already have asked someone else to form a government.
The Tory on Question Time last night was saying no PM has ever resigned mid-term and gone immediately without waiting for a successor to be appointed. That's bunkum. Chamberlain, Eden, Macmillan, all resigned without knowing who would succeed them, but a new PM was appointed next day. The monarch just took soundings about who ought to be asked to form a government.
Though the best bit was after Melbourne was dismissed by the king in 1834 - Lord Liverpool wouldn't do it, and suggested Robert Peel, but he was on holiday so a civil servant (Hudson?) was despatched to try and track him down. He found him (and Mrs Peel) in Italy. Peel says, "What are you doing here?" "To invite you to be Prime Minister." After an argument about how Hudson could have got there quicker by a different route, Mr & Mrs Peel set out home (through a riot, and floods); he hired a private carriage from Dover to go straight to the King to accept office. He lost the ensuing GE a few weeks later.