Stoke, a Premier League club 18 months ago, is bottom of the Championship with just eight points from 15 matches.
Nathan Jones was sacked last week, but the Potters' poor form continued with a 2-0 home defeat to West Bromwich Albion under the caretaker charge of former player Rory Delap.
Stoke has now agreed a deal for O'Neill ahead of a clash with fellow struggler Barnsley, yet he will take on a dual role initially.
The Irish Football Association confirmed O'Neill would oversee Northern Ireland's remaining two UEFA Euro 2020 qualifiers and any subsequent play-off matches.
Irish FA chief executive Patrick Nelson said: "We reluctantly agreed to allow Stoke to talk to Michael after they met the compensation requirements. Michael has now agreed terms with the Championship club.
"Naturally, we are extremely disappointed that Michael is leaving us.
"However, we are delighted all parties have agreed Michael will be in charge of the Northern Ireland team for the games against Netherlands and Germany and potential Euro 2020 play-off matches next March."
Northern Ireland is third in its qualification group, three points behind leader Netherlands and second-placed Germany, its final two opponents.
O'Neill has signed a three-and-a-half year contract with Stoke.