Rosemary thrives in full sunlight. If it is planted in shade or brought indoors for the winter, the leaves and even whole branches may start to turn brown or even black as the plant sheds them for lack of sunlight energy to sustain them. If rosemary stays dry for too long, the plant responds in a similar fashion, dropping parts it can no longer sustain.
Aphids and whiteflies prey on rosemary. When the population of these small, sucking insects gets particularly high, the accumulation of their leavings on the branches of the rosemary plant attracts black sooty mold. The mold does little harm to the rosemary itself, but if it covers too many of the leaves for too long, the rosemary can no longer photosynthesize. Insecticidal soap sprays doused over the plants, insects and mold helps with both the infestation problem and helps wash away the black mold.
Overwatering rosemary, or allowing the roots of the plants to sit in soggy soil, leads to root rot diseases caused by Phytophthora fungi. As the disease progresses, branches and leaves of the rosemary plant can no longer access nutrients and water from the roots, and die off. The dying leaves may turn black or brown. Infected bark may also spill black sap onto the leaves.
Most issues that lead to blackening rosemary leaves are caused by planting rosemary in the wrong spot. The ideal place to grow rosemary has good drainage to prevent root rot, full sun to prevent die back, and access to water during severe droughts. Planting rosemary outside in an exposed area ensures plentiful air circulation to discourage insect infestation and access to insect predators in case an infestation comes along.