Yes, when slavery was existing it was allowed to sleep with a girl slave and practice sex with her.
However, slavery is no longer existing. Islam; per Quran God revelation to prophet Muhammad; started while slavery was a normal trade system in Africa, Europe, the USA, and many countries of the world.
Islam rules are encouraging limiting slavery by God rewarding of those who free their slaves in compensation of their sins. The another rule was that if one gets a child through sex with a slave woman, then both the child and his/her mother are set free.