Birth control after D&E

So two weeks ago I lost my baby at 23 weeks due to an infection in my uterus in which I had to have a D&E. Before I was pregnant I was on the pill then I switched to the depo shot, I still have 5 boxes of birth control pills that aren't expired. Because the doctor told me to wait 3 months before I try to get pregnant again I was wondering if it's best to get back on birth control for those 3 months then stop and try to conceive. Also would it be okay for me to take the pills that I have left or is it best to get newer ones from my doctor.