Speed always involves distance and time, so you can't treat 6km alone as a distance without considering time. Hence the use of the relationship x=vt below.
x=vt where v=speed and t=time. Let t1 be the time to go from O to P and t2 the time to return to O from P, then t1=x/5 and t2=x/6. The total time t=t1+t2=x/5+x/6=11/2.
So the equation is x/5+x/6=11/2.
To solve it:
(6x+5x)/30=11/2,
11x/30=11/2,
x/30=½,
x=30/2=15km.
(Knowing x=15km, we can see it takes 15/5=3 hours to go from O to P, and it takes 15/6=5/2=2½ hours to go from P to O. Add these times together: 5½ hours = 11/2 hours.)