Can't help but think about random stuff instead of focusing on being in the moment

I’m the kind of guy who only ever had ED when in a sexual relation with a partner. Never had any issues on my own, and I’m getting over ED while with a partner as well.

That said, it looks like I’m getting too comfortable when with a partner, because at any given moment my mind will always be partly focused on whatever I’m supposed to be doing, and partly thinking about random unrelated stuff. This is useful in the day-to-day since it facilitates multi-tasking, but since this habit made its way into sexual situations, I’m basically treating them like any other casual setting instead of focusing on it and enjoying myself. This goes so far as to talking to them about their day or job or whatever (or mine).

What can I do to fix this, or make do with the partial attention that I can get?