She said he was a detective.

Literal

She [topic-は] him [object-を] detective [as-だと] said.

The ~を~と言う pattern functions as 'call X (a) Y' or 'say (that) X is Y' — を marks the subject of the embedded predicate (a small-clause object), and と quotes the predicate. The だ before と is the copula marking 探偵 as the predicate inside the quoted assertion. Compare with the more straightforward reportative ~と言った, which would quote a full sentence. This compact ~を~だと construction is typical when paraphrasing what someone said about a third party.