For example I sent Infernape and use stealth rock. then I withdraw it and send roserade, could I use toxic spikes so it will hurt the foe a lot when opponent switching out?
You can, you can use stealth rock, toxic spikes and spikes all at once. Foretress can learn all 3. It's just very difficult to set up.