I commute 4 days a week, minimum 12 miles each day (round trip) but often extended one or both ways. I still get out for 2-3hrs on a Friday, sometimes for an hour or so at the weekend, and a couple of night rides a month. I’m 52, and whilst I sometimes feel tired or the legs feel a bit dead, don’t usually have any specific injuries/niggles to deal with.
For me, commuting by bike is both about getting to/from work, but also some ‘me’ time. I’m also fortunate to be able to choose a variety of semi-rural roads/trails to make the commute more enjoyable.
I’d get your knees looked at because if there is us an underlying problem, none of the potential solutions (ebike, or drop some of the commutes in favour of more play-time) are going to work out in the long-term. 40 isn’t so old really; you potentially have another 30-40 years riding ahead of you, but if there is a problem with your knees, that will become limited.
So, maybe see your GP, but probably also supplement this with seeing a sorts physio for some assessment / knee strength & stability exercises, and suitable stretching regime.