The cake attack, which occurred on Halvorsen's first day in office, was an effort to stimulate debate on weather the country was well served by hiring a finance minister from the Socialist Left Party, the student said.
The Director of Public Prosecutions will decide how the student will be punished for the attack. The maximum penalty is 15 years in prison.
Although Halvorsen has not pressed charges over the incident, she will be at the trial, set to be held in Oslo on October 11.
In a similar incident in Sweden, a teenager threw a cream cake at King Carl Gustaf when he was making a public appearance in Varberg. The teen scuffled with the king's guards, but was unharmed.