Preferably within a week. I suggest organizing by year and location. Then back them up someplace other than your phone or the cloud, like an external hard drive.
That said, Apple’s and Google’s most common image management software can be very helpful. (The app is called Photos in both cases.) Adobe Lightroom Classic combines an organizational framework with image-editing options.
I make a folder for every year, and within each year I have folders for each trip, labeled by month and destination. I mark the best of the images and videos with stars and usually delete the rest.