To rotate an object in a circle object needs centripetal force
in above example tension is providing centripetal force
in case of sun and planet there is no string
but we have gravitational force acting between them which is attracting force
so here Sun is applying an attractive force on the planet which provides the centripetal force
This force is gravitational force between the sun and the planet