It's generally ok to sleep in your compression socks. You can even wear compression socks 24 hours a day if you like but they tend not to have the same level of compression as medical grade compression wear. Generally the higher level compression wear is used during the day and the lower level compression is worn in bed but your doctor or surgeon can offer you advice on when they should be worn.