It is highly unlikely that you will develop myiasis just from sleeping near a moldy sandwich infested with maggots.
Next Steps
Dispose of the sandwich and bag immediately. Wash your bedding and clean the surface where the bag was sitting.
Health Tips
If you notice any new, boil like lumps on your skin, unusual discharge from your nose or ears, or severe gastrointestinal upset, consult a doctor