Should I separate grounds with optocoupler and dc converter?
It is hard to say without knowing your application and requirements what you should do.

If the DC-DC converter is not isolated, then the grounds of the 24 V and 3.3 V logic are connected.  In that case, there is probably no advantage to splitting them at the opto-coupler, and also probably no reason to use an opto-coupler at all.

On the other hand, if the DC-DC converter is isolated and that isolation is needed, then you would use opto-couplers (or other isolation devices) for all signals that cross the boundary.