When you rear beetle larvae, you may sometimes notice small to large black or dark colored spots varying in sizes on their body. This is currently known as the Black Spot Disease among the scarab enthusiasts, and it can occur when larvae are wounded, and gets bacterial infection on the site. Although this term ends as a "disease," it actually is not a disease. We are still researching where the term [Black Spot Disease] first came up with scarab rearing, but we are uncertain about its source. In our opinion, the term came from plants. The black spot itself isn't bad, but is actually a good thing. This is like a crust you get after you hurt and bleed. This closes up the wounds. The factor that originally causing the black spots (or the wound) is the problem here.
What's the reason? Sharp Object vs. Pests
Based on its symptoms, you can easily identify the cause of black spots. If you see a single to couple black spots on a larvae, there is very likely a sharp object is in your container. Try to locate it and remove it as soon as possible for the future prevention.
If your larvae has a multiple small to large black spots dispersed over the entire body, you very likely have parasitic pests (such as mites) in your container. You should either sterilize substrate, or clean your larvae and exchange the substrate entirely. Make sure you clean the container as well.
Treatment
As black spots are not a disease itself, but a crust, there is no treatment you can provide for larvae with black spots. However, as they molt, black spots may disappear or shrink in size. If black spots are not too heavily occurred on third instar larvae, they won't have problem pupate and emerge to fine adult beetles.
Prevention
To prevent larvae having wounds, we suggest you to have a regular monitoring of your larvae, make sure you don't have any pests, check humidity of substrate, and its condition at least every 4 to 8 weeks if you can.