A person of interest was detained Tuesday, Fox 11 reported citing officials.
The sheriff's office said at a news conference the incident happened shortly after 5:30 p.m. at the Jack in the Box restaurant in Alhambra, a suburb east of Los Angeles.
"The deputy is currently in critical condition and he needs our prayers... to see whether he can pull through," Sheriff Alex Villanueva told reporters.
The deputy, a 13-year veteran of the department, was off-duty and in civilian clothes at the time of the shooting.
"Nothing overtly that would indicate he was a law enforcement officer," sheriff's Homicide Bureau Capt. Kent Wegener said. "He was off duty."
The shooting was captured on surveillance video and shows the deputy entering the restaurant, ordering food, and then waiting at the counter for his order.
As he was standing at the counter waiting for the food, the gunman approached and shot him once in the head, then left immediately, Wegener said. The deputy was rushed to County-USC Medical Center, where he remains hospitalized.
"There doesn't appear to be an overt motive" based on security video footage, Wegener said.
The gunman was described as a man in his 20s, about 5-feet 9-inches to 5-feet 11-inches tall, and was wearing a light-colored fedora hat, sunglasses, a burgundy button-down short-sleeved shirt, slim fitting blue jeans. Officials said he was armed with a handgun at the time of the shooting.
The suspect was later seen driving northbound on Fremont Avenue in a 2006 Kia Sportage 4-door SUV with paper license plates.
Investigators said the suspect apparently drove to a neighborhood just before 6 p.m. and changed his clothes into a black T-shirt and dark-colored jeans before taking off the hat and sunglasses and leaving the neighborhood in the Kia SUV, Fox 11 reported.
Several people who witnessed the shooting inside the restaurant were being interviewed by investigators.
The name of the deputy was not immediately released, and officials said the investigation was ongoing.
Anyone with information about the shooting was asked to call the Los Angeles County Sheriff's Department's Homicide Bureau or LA Crime Stoppers.
Fox News' Mike Arroyo and The Associated Press contributed to this report.