You should move those two loops closer together above and below the extrusion so that the verts are evenly spaced, or wedge it out. Post file and I can try to show you.
For very sharp corners, the key is to get 3 vertices per corner: one in the middle and one on each side that sharpen the shape. On a curved surface, the surrounding faces need to be somewhat evenly sized. In this one, some of the horizontal edge loops are not needed so those can be taken out.
First of all, thanks for your once again very quick and good answers!
Try to add new object, more easier to handle afterwards also and local polycount is big plus always + less shading problems.
@TynkaTopi: You mean adding a separate mesh for the cuboid? But then I would loose the soft joints between the cylinder and the cuboid…
@JA12: I tried to keep the vertex count as low as possible. You’re compensation the problem by increasing the resolution. I was hoping that there is a way to solve the problem without increasing the complexity.
Try creasing the edges instead of adding edge loops.
@m9105826: The creasing gave unwanted effects and it is not possible to precise yet rounded edges along the cuboid.
If you want the surface to be smooth, you need geometry, you also need some or all of that geometry to be in the editing cage if you’re defining hard edges with it too. Mine without subsurf was 512 faces, yours in the pic is 304 with subsurf level 1 (not counting the ngons on top), increasing that to subsurf level 2 would give you 1216 faces.
Of course if you don’t want/need it perfect, something like this could do as well (376 faces with subsurf level 1)