This was one of my first Beethoven sonatas, and I played it at my first recitals. It's great that you're identifying the issue that you're talking about. Like with many things, recognizing it is half the battle.

Before talking about anything more involved like how to practice it, it might be good first just to say what's the basic thing that has to happen:
You need to make the outer fingers (i.e. 4th and 5th, the fingers playing the main melody in each hand) stiffer than the other fingers when you play those notes.
I rarely see it put this simply, but that's the basic way in general to bring out a voice when the hand is also playing other notes.
Were you seeing it that way, or is it sort of something new? If it's new, how about just trying to practice it a few times with that in mind, and see if you don't feel on the right track right away.
An additional thing is to sort of "throw" the hand in the direction of those outer notes. That helps. But making those fingers 'stiffer' is the basic thing. And also, don't
keep the fingers stiffer except just for an instant when hitting each note, because otherwise they'll get tense and tired.