The thing is that it's kind of hard to make a recommendation for only $400 because you're going to need a platform upgrade and the only platform that is currently viable is AM5. AM4 and LGA 1700 are both dead and any further upgrades from them would require a new motherboard again so neither of them are good directions to take because you'd be basically throwing away any money spent on a motherboard.
To upgrade your platform to AM5 (the only one worth buying right now) would require a CPU, motherboard and DDR5 RAM. I'll try to keep everything as cheap as possible and even with the cheapest parts, the performance would be like day and night compared to your i5-9400f. I'll keep it as close to $400 as I can:
CPU:
R5-7600 - $233
Motherboard:
Gigabyte B650M DS3H - $150
RAM:
Patriot Signature Line DDR5-4800 2x8GB - $57
Total: $440
The Ryzen 5 7600 comes with a usable air cooler so you this is all you'd need to make a gigantic platform upgrade. To give you an idea of how fast the R5-7600 is, just look at this chart:
You'll see here that the R5-7600 is 15% faster than the i5-12400, a CPU that is
three generations newer than your i5-9400f. None of the Intel 9th, 10th or 11th generation CPUs are fast enough to even be on this chart. Any task that is the least bit challenging to your i5-9400f would be child's play for the R5-7600 with one eye closed and one hand tied behind its back. It also has an RDNA2 IGP which, while not very useful most of the time for you, would be a life saver if your RTX 2060 ever started acting up.
I know that it's 10% above your budget but I truly believe that it's the best you can do for around $400 by a country mile. This AM5 motherboard will remain viable for many years to come (unlike an AM4 or LGA 1700 motherboard), and you'll discover the joys of drop-in CPU upgrades. This is as cheap as AM5 gets but it's totally worth it. As I said, for you it will be like night and day.