On your question you wrote: customs officer, so your question is about customs. So practically where you embarked your baggage.
Technically it is about where you previously cleared customs (which could be various places), but mostly irrelevant for air travelers.
So, in your case, you can write Sofia, Bulgaria (if you started there) or Bulgaria or also just European Union.
Note: I would prefer the most specific item, because customs also handles agricultural security, so you would not have further questions, e.g. if some regions of Spain have further restrictions, e.g. on food or a requirement to not stay on a farm for e.g. last 48 hours.
Things would be more complex if you stopped in e.g. Canada, you go out from the airport, and you bought something special.
In any case, do not worry (if you can speak some English). US immigration officers and custom officers are friendly and very talkative: if you have any question, just ask them: they are happy to talk. Just do not hide important information.
There is no trick here, and this isn’t a paper form where you only get one chance to enter a single word answer. I typically answer with the country I have spent my trip in (or live in) first, and then add that I transited in another. So for your case:
Sofia, with a change of planes in Munich
(I almost always answer with cities rather than countries, it’s an old habit of mine, and no customs officer has ever had a problem with it.)
Lying to customs officers is very bad. So just answering literally with the place you changed planes might be seen as trying to hide your origin. Answering with only your origin, if the officer knows there are no direct flights, might be seen as trying to hide your transit. Giving both pieces of information is easy and much safer than only giving either one.
Credit:stackoverflow.com‘