Once the property of Ochi of Bestoon, a Sith assassin, D-O was a specially designed droid for storing and retrieving data. A droidsmith built the droid, but Ochi murdered the droidsmith. On Pasaana, BB-8 brought the droid back online in 35 ABY. Later, Rey further repaired him on Kijimi. D-O, an easily excited little droid, became friends with the Resistance droid and desired to emulate him.
D-O communicated in a simpler form of droid binary that was more easily understood by non-droids than typical droid language. He could also speak in Basic, although his vocabulary was limited and his speech was often distorted, accompanied by a noticeable stutter. D-O's cone was fitted with a cold storage unit, separate from his droid brain, which allowed him to store confidential information without being able to access it himself.

Sometime before or during 21 ABY, a droidsmith constructed D-O, a droid. However, the Sith assassin Ochi of Bestoon killed D-O's creator and then took D-O for himself. D-O was kept on Ochi's ship, the Bestoon Legacy. While serving Ochi, D-O accumulated a large amount of data and files about the Sith world of Exegol in the Unknown Regions and the enigmatic Sith Eternal, the group Ochi served. His master also mistreated D-O.
While being pursued by Jedi Luke Skywalker and General Lando Calrissian on a mission to Pasaana, Ochi became stuck in quicksand and died. His ship was left abandoned in the desert, with D-O deactivated inside.

Years later, in 35 ABY, a team consisting of the Jedi Rey, Finn, a former First Order stormtrooper, the pilot Poe Dameron, the droids BB-8 and C-3PO, and the Wookiee Chewbacca journeyed to Pasaana. They were following the trail left by Luke in his search for a Sith wayfinder, an object that the Resistance now needed to thwart Darth Sidious and the Sith Eternal's grand plan. The Sith had secretly been building a massive fleet of Xyston-class Star Destroyers, known as the Final Order, on Exegol, which required a wayfinder to locate because the route to the Sith world was dangerous and uncharted. While exploring Ochi's abandoned ship, BB-8 discovered the deactivated D-O, who had been left alone and covered in dust. BB-8 quickly reactivated the small droid, who showed his appreciation for being brought back to life. However, when Rey attempted to touch him, the little droid recoiled, indicating that Ochi had mistreated him. Rey reassured the droid that he was safe and now with them.
D-O accompanied his new companions on a journey to Kijimi to find the droidsmith Babu Frik, who could help C-3PO read an inscription on Ochi's dagger stored in the droid's memory. While on Kijimi, Rey discovered that Chewbacca was still alive. D-O, along with Poe, Finn, and BB-8, traveled to the Resurgent-class Star Destroyer Steadfast. Although they became separated, resulting in the capture of Finn and Poe, who had just freed Chewbacca, they were rescued by General Armitage Hux, who had betrayed the First Order. D-O informed Threepio that their friends were ahead, and they boarded the Millennium Falcon together, leaving Hux behind.
After escaping from the Steadfast, the Falcon crash-landed on Kef Bir, where the wayfinder was located, as indicated on the dagger. The wayfinder was located in the ruins of the second Death Star. D-O inquired about the wreckage, and Rey explained that it was the Death Star, remnants of an old war. After locating the wayfinder in the ruins using the dagger, they were interrupted by the arrival of Company 77, who demanded to know why the Resistance was on their moon. D-O curiously examined the orbaks but became frightened by them. After Rey departed, D-O expressed his longing for her. Finn asked the droid his name and then discovered that D-O possessed a wealth of information about Exegol, which had been Ochi's intended destination before his death.
The information D-O possessed, combined with a live transmission from Rey piloting Luke Skywalker's T-65B X-wing Red Five, allowed the Resistance to pinpoint Exegol and the Sith fleet, providing them with a chance to prevent the impending destruction. Following a fierce battle and the arrival of the Citizens' Fleet, the Sith Eternal was defeated, and the Emperor was finally vanquished. D-O joined the celebrations with his newfound friends, free from the clutches of evil forever.
D-O made an appearance in Star Wars: Episode IX The Rise of Skywalker, the 2019 film that concluded the Star Wars sequel trilogy. J.J. Abrams, the director, provided the droid's voice, while Robin Guiver and Lynn Robertson Bruce operated the puppet. At the Episode IX panel during Celebration Chicago, the droid was first introduced. In the 2020 animated film The LEGO Star Wars Holiday Special, Matthew Wood, a Lucasfilm sound editor, took over the voice acting duties.
Ducklings served as a partial inspiration for the droid. The comic Spy vs. Spy served as another visual reference. D-O's personality was based on Terrio's dog George, whom Terrio had saved from an abusive owner. Abrams' voice was initially intended to be temporary, but Chris Terrio, the screenwriter, watched a few cuts with Abrams' voice as D-O and decided that the anxious politeness in Abrams' performance was ideal for the droid. Other actors were considered, but Terrio persuaded the director to keep the voice.
Ultimate Star Wars, New Edition stated before Episode IX's release that Babu Frik created D-O; however, the film revealed that this was incorrect. According to Star Wars: The Rise of Skywalker: The Visual Dictionary, a companion book to the film, D-O was created by an unnamed droidsmith who was killed by Ochi. The notion of D-O belonging to Babu Frik originated from an earlier version of the script, in which BB-8 would fix the broken D-O in Frik's workshop, and the droid would then imprint on BB-8.