This question is really answered by what martial art you’re learning. normally for striking arts like Boxing or Kickboxing you can be waiting a little while, 3-6 weeks would probably be the earliest you could try any sort of contact training. Some old school trainers might get you to spar straight away but this sort of training style is going out the window as while it can provide a roster of strong fighters, it also pushes away more casual participants.
With grappling arts however it is commonplace to begin sparring on your first session, this is due to there being no strikes, allowing you to train at a high intensity with less risk of immediate damage.
it is also important to think of what constitutes sparring, personally I would place contact drills into a different column to full contact open sparring, however you still probably shouldn’t be taking part in any full contact drills either, not until you’ve proved that you can actually control yourself, both athletically and emotionally.
if you personally have been training consistently for a while aren’t sure when you should start sparring, you should ask your coach, your coach, if they’ve been keeping an eye on you, will be able to tell you if you’re ready to spar or how close you might be. For some coaches asking them this question is the turning point for letting them know your ready to take the next step in training.
For full contact sparring, where the timer beeps and then all bets are off, it isn’t unheard of to be training for 6 months before you get the nod from your coach.