This is an excellent description of exactly how the urea breath test is done and why it is useful in detecting whether there might be H. pylori.
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1123218/
Berger A. Helicobacter pylori breath tests. BMJ. 2002;324:1263. doi: 10.1136/bmj.324.7348.1263 PMCID: PMC1123218 PMID: 12028983
As described in this paper,
“Patients first drink a sachet of orange juice or citric acid. This
rapidly closes the duodenal sphincter to contain the stomach contents.
They are then asked to blow through a straw into a glass tube with a
screw cap lid. This provides the baseline sample. Next, they consume a
drink containing 13C enriched urea (about 100 ml) and after 30 minutes
repeat the blowing exercise into a second tube. This provides the
post-dose sample. Both samples are sent away for carbon dioxide
isotope analysis by mass spectrometry (laboratories usually return the
results within a few days). The level of 13C in the baseline sample
will be normal. If levels rise in the post-dose sample, this suggests
the presence of H pylori. The enriched urea provided by the testing
kit must have been broken down to produce high levels of 13C in the
breath and this implies the presence of urease excreting H pylori in
the stomach. “
Peptic ulcer disease is a term that includes both ulcers in the stomach (i.e., gastric ulcers) and ulcers in the duodenum (duodenal ulcers). H. pylori is involved in the pathogenesis of both gastric ulcers and duodenal ulcers but the mechanisms are different.
This lecture prepared by Dr. Mahra Arafah and Dr. Ahmed Al Humaidi for medical education at the King Saud University and posted on slide share provides an especially understandable explanation of the complex pathogenesis of peptic ulcers. To understand better the role of H. pylori in the pathogenesis of gastric ulcers compared with duodenal ulcers, see in particular slides 21-26.
https://slideplayer.com/slide/13083448/
What is explained in detail in the lecture is summarized in the abstract of a paper by Walker and Crabtree (1998):
“Helicobacter pylori is a gram-negative spiral bacterium confined to
the habitat of gastric-type epithelium. [bolded for emphasis] H.
pylori causes duodenal ulceration by a cumulative effect of antral
predominant gastritis with increased acid secretion, consequent
gastric metaplasia in the duodenum (a site of further colonization by
H. pylori), duodenitis, reduced duodenal bicarbonate secretion, and
mucosal damage.”
https://pubmed.ncbi.nlm.nih.gov/9928373/
As explained in a 1996 article by Khulusi et al.:
“Gastric metaplasia (GM) of the duodenum is the replacement of groups
of duodenal epithelial cells by those with a gastric mucosal
phenotype. It is a feature of the duodenal bulb and is generally
believed to occur as a nonspecific response to acid/peptic damage and
is strongly associated with duodenal ulceration.”
Khulusi S, Badve S, Patel P, et al. Pathogenesis of gastric metaplasia of the human duodenum: role of Helicobacter pylori, gastric acid, and ulceration. Gastroenterology. 1996 Feb;110(2):452-8. doi: 10.1053/gast.1996.v110.pm8566592. PMID: 8566592.
In answer to your question, the urea breath test is used to detect/diagnosis H. pylori in the stomach. The test can be useful in evaluating people with symptoms of duodenal ulcer but does not specifically detect/diagnose H. pylori colonization of the duodenum.