It is an indirect object because it requires a preposition (a in this case). Portuguese and English grammars differ in this respect. They work the same in a sentence like:
Pergunta ao João a morada dela
Ask João her address
Here ao João is the indirect object, just as João in English (except that Portuguese requires a preposition and English does not), and a morada dela / her address is the direct object. The two Languagess differ if the “old direct object” is no longer there explicitly, even though we can understand one implicitly:
Se queres saber a morada dela, pergunta ao João [implicitly understood a morada dela]
If you want to know her address, ask João
Here, I’ve now learned, in English grammar João is reanalysed as direct object, because the rule is there is an indirect object only if there is a direct one too (although some grammarians admit exceptions). In Portuguese grammar, ao João is still the indirect object even with no direct one. The best way to tell in this case is that ao João can be replaced with the indirect object pronoun (lhe) but not with the direct object pronoun (o)
O João deve saber a morada dela. Pergunta-lhe [lhe = a ele]
João probably knows her address. Ask him
It’s just the same with your example:
Se tiver alguma dúvida, pergunte a um funcionário
Se tiver alguma dúvida, procure um funcionário e pergunte-lhe
It is the other way round with verbs like interrogar, which take a direct object only:
A polícia prendeu o suspeito e interrogou-o
(You can tell the difference only with the third person: lhe(s) ≠ o(s)/a(s). For the other persons indirect and direct object pronouns coincide: me, te, nos, vos.)
Furthermore, some verbs, like telefonar, take an indirect object but cannot take a direct one:
Espera, tenho de telefonar ao João. Ok, telefono-lhe mais tarde
Wait, I have to call João. Ok, I’ll call him later
Generally: how to identify the indirect object (in most cases)
Generally the Portuguese direct object cannot have a preposition (but there are always exceptions!). So if it has a preposition it is (generally!) an indirect object or it is an adjunct. I’ll now switch to Portuguese terms to make sure there’s no confusion with English grammar. To tell whether a prepositional phrase is an objeto indireto or an adjunto try and drop it: you can still get a full sentence without the adjunto but not without the objeto indireto: vou ao cinema à noite; vou ao cinema is still fine because we only dropped the adjunto à noite; vou or vou à noite is not a full sentence because we dropped the objeto indireto ao cinema. Ao cinema is a type of objeto indireto called complento oblíquo. You can tell it because you cannot replace it with the indirect object pronoun: vou ao cinema is fine; *vou-lhe is wrong. If you can make that replacement it is a complemento indireto: telefona ao João, telefona-lhe. Again, there are a few exceptions to this!