A cupcake was a form of baked food that originated with Human civilizations on Earth, a single-serving cake that is baked in a small cup-sized container. Cupcakes are often frosted with sugary toppings, just as full sized cakes are. When used in reference to people, it usually functions either as a term of endearment or of belittlement.
In the year 2255 of an alternate reality, James T. Kirk once provoked a bar fight in Iowa by calling an over-aggressive Starfleet cadet "cupcake", as a diminutive nickname that was taken as an insult. The same cadet graduated from Starfleet Academy at the same time as Kirk, during the Vulcan Crisis, and got a chance to use the term as an insult to Kirk—while arresting him for trespassing in engineering aboard the USS Enterprise. (TOS movie: Star Trek)
In the late 2350s, USS Fortuna Lieutenant Kathy Li also used "cupcake" as a nickname, for her lover, Lieutenant William Riker. When Riker was reassigned to a posting on the surface of planet Betazed, Lieutenant Li baked him an actual cupcake for their last night together. (TNG novel: Imzadi)