Usualy for improvised stuff, you may need some theoretical knowledge of scales & stuff...
For worked out solos I got nothing to say , theory will help but it's more about creativity ... Anyway, you can try some improvising then clean it out to be a nice worked out solo.