It is not known when Cui Gong was born. He was from the "Second Boling branch" of Cui clan of Boling. Cui Gong's grandfather Cui Yi and Cui Gong's father Cui Ting were served as a prefectural prefect. Cui Ting had eight sons, all of whom were considered capable and who later became Tang officials, and it was said that they were compared to the Han Dynasty official Xun Yu's father and his seven uncles, who were known as the "eight dragons." Cui Gong had the same mother as his older brother Cui Guan, who would also have a prominent career of his own. It was said that Cui Gong passed a special imperial examinations for making prompt rulings, and subsequently served on staffs of regional governors. It was also said that he was serious in disposition, and was skillful in administration.
During Emperor Wenzong's reign
Early in the Taihe era of Emperor Wenzong, Cui Gong served as the prefect of Si Prefecture, and later was recalled to the capital Chang'an to serve as the minister of palace supplies. In 833, he was commissioned at the military governor of Lingnan Circuit and the prefect of its capital Guang Prefecture. Before he departed, he met with Emperor Wenzong to thank the emperor for the commission. Emperor Wenzong asked him how he planned to govern the circuit, and Cui was able to respond clearly and concretely, impressing Emperor Wenzong. At that time, Gao Yu was the military governor of Wuning Circuit, which was well known for its unruly and difficult-to-control soldiers. As Gao was unable to control them, Emperor Wenzong wanted someone with serious presence to govern Wuning, and he therefore decided to transfer Cui to Wuning to serve as its military governor and the prefect of its capital Xu Prefecture ; Wang Maoyuan was sent to Lingnan instead. It was said that after Cui arrived at Wuning, he was able to draw a balance between strictness and grace, causing the Wuning people to fall into line. In 837, Cui was recalled to Chang'an and made the commander of the Chang'an police. Soon thereafter, he was made the mayor of Jingzhao Municipality. That year, there was a serious drought in the region. Cui requested that the Chan River waters that usually were directed into the palace be reduced by 90%, so that the water could be used to water the people's fields, and Emperor Wenzong agreed. In 838, when an assassination attempt was made against the chancellor Li Shi, Cui, who was unable to capture Li Shi's would-be assassins, was punished by being stripped of part of his salary.
During Emperor Wuzong's reign
Emperor Wenzong died in 840 and was succeeded by his brother Emperor Wuzong. At that time, Cui Gong was serving as the minister of justice, and soon after Emperor Wuzong's ascension was made a chancellor de facto with the title Tong Zhongshu Menxia Pingzhangshi. He was also made the director of the salt and iron monopolies. When, in 841, Emperor Wuzong, believing the former chancellors Yang Sifu and Li Jue had opposed his succession and therefore wanted to force them to commit suicide, Cui, along with his fellow chancellors Li Deyu, Cui Dan, and Chen Yixing, interceded, and Yang and Li Jue were spared of their lives, although they were exiled. It was said that Cui Gong was friendly with Li Deyu, who was then, effectively, the leading chancellor. However, in 842, there was an occasion when Cui Gong recommended Liu Gongquan to be an imperial scholar at Jixian Institute and serve as its acting director. Li Deyu, displeased that this recommendation did not come from himself, found an excuse soon thereafter to have Liu demoted. Further, Cui Gong had a rivalry with another official, Cui Xuan. After Cui Gong was removed from his chancellor post in 843 and made You Pushe, Cui Xian succeeded him as chancellor and the director of salt and iron monopolies, and accused him of having misused the salt and iron monopoly funds from Songzhou and Hua Prefectures, as well as being protective of the warlordLiu Congjian. As a result, Cui Gong was exiled and demoted to be the prefect of Li Prefecture, and yet later further demoted to be the military advisor to the prefect of En Prefecture.
During Emperor Xuānzong's reign
In 846, after Emperor Wuzong died and was succeeded by his uncle Emperor Xuānzong, Cui Gong and four other former chancellors that Emperor Wuzong had exiled — Li Zongmin, Niu Sengru, Yang Sifu, and Li Jue — were allowed to be moved closer to Chang'an; in Cui's case, he was made the secretary general of An Prefecture. Sometime thereafter, he was made an advisor to the Crown Prince, and then the military governor of Fengxiang Circuit. In 848, in the middle of Tang campaigns to recover territory that had been lost to Tufanever since the end of the Anshi Rebellion, Cui had a victory over Tufan forces and recaptured Qingshui. In 849, Cui Xian was again chancellor. When Cui Gong heard this, he offered to resign on account of illness. Emperor Xuānzong made him an advisor to the Crown Prince, with his office at the eastern capital Luoyang. Sometime before 851 he served as defender of Luoyang, and in 852 he was made military governor of Fengxiang Circuit again. He died in office, probably in 854, as in this year a new military governor of Fengxiang Circuit was appointed. His grandnephew Cui Yuan later served as a chancellor during the reigns of Emperor Zhaozong and Emperor Ai, near the end of Tang Dynasty.