Microsoft has a policy of supporting only the three most recent major versions of macOS.
Microsoft Support – Upgrade macOS to continue receiving Microsoft 365 and Office for Mac updates
"Note: As new major versions of macOS are made generally available, Microsoft will remove support for the oldest major version and support the newest and previous two major versions of macOS."
Ventura is still good enough to install and use Office for Mac 2024 – but the latest update to Microsoft 365 for Mac (the subscription version of Office) doesn't support anything less than Sonoma. Should Microsoft decide that they are going to update Office 2024, the minimum requirement for it could change to Sonoma overnight.
If you get a new Mac for the purpose of running Office or 365, I would think that you'd want to get a recent Apple Silicon Mac – say, one with a M3-, M4-, or M5-family processor. There are only a few Intel-based Macs that can upgrade as far as Tahoe, and Tahoe is the last major version of macOS that will run on any Intel-based Mac at all. Therefore, if the idea is to get a new machine that will be able to run the latest Microsoft products for some time, a fairly recent Apple Silicon Mac would make the most sense.
[Edited to fix typo.]