The US Constitution does not establish a time limit for overriding a veto; therefore, it is up to each chamber to establish its own rules on the matter, as provided in the rules clause of Article I, Section 5 of the Constitution [1]. In practice, each house deals with veto overrides promptly, though their procedures differ slightly. In the House of Representatives the matter is typically disposed of immediately [2]:
On the day a vetoed bill and accompanying presidential message are received, the Speaker lays
the message before the House. The veto message is read and entered in the House Journal. It is
not necessary for a Member to make a motion to reconsider the vetoed bill. If no Member seeks
recognition after the message is read, the Speaker will put the question of overriding the veto
before the House
The Senate process apparently takes a little longer, but is otherwise similar:
When the
Senate receives a vetoed measure from the President or the House, it is quite common for it to be
“held at the desk” for several days and considered only after unanimous consent has been reached
on the terms of its consideration.
So, normally the override question is settled within a few days and not allowed to remain open. However, either house could delay consideration through a variety of procedural maneuvers. At this point the motion appears to be subject to the same rules as any other piece of business before the body, which is to say that it would expire when the house adjourns sine die at the end of a Congress. This seems to be confirmed in several reports, though all the ones I could find merely state the fact without further elaboration. For example [3]:
If Congress attempts to override the veto it may do so at any time during that Congress
To summarize, the generally accepted answer seems to be that in both houses the measure is promptly formalized as a motion, where it is then subject to the usual rules of procedure. Usually a decision is made within a few days, but in principle they have until the end of the Congress.
Rules clause of the US Constitution
Veto Override Procedure in the House and Senate, Congressional Research Service Report
The Presidential Veto and Congressional Veto Override Process, Center for Legislative Archives