It's safe to stain pressure-treated lumber as long as it's dry before the stain is applied. Most pressure-treated lumber can be stained within 30 days after a project is built, although some boards are manufactured with a water-repellent coating that requires additional drying time.
The easiest way to test whether pressure-treated wood is ready for staining is to splash a few drops of water onto the lumber. Water that beads on the surface indicates the wood is still too wet for staining. Water that soaks into the boards indicates that staining is appropriate. Yellawood recommends a water-repellent stain that includes an ultraviolet stabilizer.