The position of Majority leader of the senate is created by the Senate Rules, which are enacted at the stasrt of every session of Congress, usually with little change.
The Senate chooses the Majority leader by vote, and can change the leader at any time. This can occur if the balance of parties changes, whether by death, resignation, special election, impeachment and removal from office or change of alignment of a Senator. This has happened in the past. It can also change if the members of the majority party decide that they want a different leader, with no change in the party balance.
This oifficial page from the Senate says:
The positions of party floor leaders are not included in the Constitution but developed gradually in the 20th century. The first floor leaders were formally designated in 1920 (Democrats) and 1925 (Republicans).
The Senate Republican and Democratic floor leaders are elected by the members of their party in the Senate at the beginning of each Congress. Depending on which party is in power, one serves as majority leader and the other as minority leader.
...
The posts of majority and minority leader are not included in the Constitution, as are the president of the Senate (the vice president of the United States) and the president pro tempore. Instead, party floor leadership evolved out of necessity. During the 19th century, floor leadership was exercised by the chair of the party conference and the chairs of the most powerful standing committees. In 1913, to help enact President Woodrow Wilson's ambitious legislative program, Democratic Conference chairman John Worth Kern of Indiana began functioning along the lines of the modern majority leader. In 1919, when Republicans returned to the majority, Republican Conference chairman Henry Cabot Lodge, Sr., also acted as floor leader. Not until 1925 did Republicans officially designate Senator Charles Curtis of Kansas as majority leader, separate from the conference chair.
- There were two majority leaders during the 75th Congress (1937–1939), Joseph T. Robinson having died in office
- There were two majority leaders during the 83rd Congress (1953–1955) Robert Taft, Jr. (R-OH) having died in office
- 107th Congress (2001–2003) From January 3 to January 20, 2001, with the Senate divided evenly between the two parties, the Democrats held the majority due to the deciding vote of outgoing Democratic Vice President Al Gore. Senator Thomas A. Daschle served as majority leader at that time. Beginning on January 20, 2001, Republican Vice President Richard Cheney held the deciding vote, giving the majority to the Republicans. Senator Trent Lott resumed his position as majority leader on that date. On May 24, 2001, Senator James Jeffords of Vermont announced his switch from Republican to Independent status, effective June 6, 2001. He announced that he would caucus with the Democrats, giving the party a one-seat advantage and changing control of the Senate back to the Democrats. Thomas A. Daschle again became majority leader on June 6, 2001.
This essay from LegBranxh says:
Put simply, party leaders are powerful because rank-and-file senators defer to them to manage the institution how they see fit. This deference is not mandated by the Senate’s official rules. Rather, it is simply grounded in its past practice. The implication is that frustrated members can easily change how the Senate operates at any point
The actual Standing Rules of the Senate do not seem to contain any provision for the choice of majority and minority leader -- it seems to be purely a matter of custom, although several rules acknowledge the existence of the position.