For any of several reasons an African cichlid may rub itself on surfaces like rocks. It is most likely a sign that the cichlid has a parasite living on its skin. However, it could also be a breeding behavior. If it is a disease, treatments exist that can make your cichlid healthy again.
Ich is a common fish disease that can infect cichlids. It is a protozoan parasite, Ichthyophthirius multifiliis. It has a complex life cycle, including a free-living stage and a parasitic stage that causes cysts in the skin of fish like African cichlids. The most obvious symptom of ich is the appearance of tiny white cysts on the body and fins. The cysts look like grains of salt on the fish. They may cause African cichlids to rub themselves on rocks to try and dislodge the parasites.
Velvet is a protozoan parasite, very similar to ich. Its scientific name is Piscinoodinium pillularis. This parasite causes much smaller cysts, that look more like powdered sugar on the skin of your African cichlid. It gives the skin a somewhat velvety-looking texture, hence the name. Again, it may cause an African cichlid to rub on rocks, trying to scrape away the parasite. The treatment for both conditions is very similar.
Though less likely, if you see your African cichlid rubbing itself on rocks, it could be a preventive health measure. African cichlids display a wide range of breeding behaviors, and some spawn on surfaces like rocks. Some African cichlids meticulously clean their rocks before laying eggs on them. They'll rub their face and lips on the rocks rather than their bodies during this behavior . Even then, you should research your particular species of African cichlid to rule out parasites if you see this behavior.
When you rule out spawning behavior, you should treat for parasites immediately. Malachite green, and other copper-based medications work against ich and velvet. You can find these at pet shops. Follow the directions on the box for the specific preparation. Additionally, while it's an often overlooked option, raising the temperature of your African cichlid aquarium to 85 degrees and adding 2 tablespoons of aquarium salt per 5 gallons of water can clear up skin parasites. Purchase aquarium salt at pet shops or use rock salt or kosher salt.