Final answer:
The sebaceous gland is responsible for producing an oily substance called sebum, which moisturizes the skin and hair and has antibacterial properties.
Step-by-step explanation:
The type of gland responsible for producing an oily substance that helps to moisturize the skin and hair is the sebaceous gland. Sebaceous glands are found all over the body, most often associated with hair follicles. They secrete sebum, which is a lipid-rich substance that lubricates and waterproofs both the skin and hair, preventing them from drying out. Sebum also possesses antibacterial properties, which helps to inhibit the growth of microorganisms on the skin. These glands are particularly inactive during childhood but are stimulated by hormones during puberty.