In general, it can often be just a make-weight. Consider these:
Tom asked Dick, 'Why did you hit Harry?'
Tom asked Dick why he had hit Harry.
In reported speech, there's no need for a comma. But in a longer sentence one would be helpful:
Tom asked Dick, surprised by the unwarranted attack, why he had hit Harry.
Now, if you change the transitive verb to something like 'questioned' (which is transitive, but not ditransitive like 'asked' ('Tom asked Dick [Obj1] a question[Obj2]'), you get a sentence that I'd be rather doubtful about:
Tom questioned Dick, surprised by the unwarranted attack, why he had hit Harry. :-?
Here you would use 'as to why':
Tom questioned Dick, surprised by the unwarranted attack, as to why he had hit Harry.
But often people (especially TV/radio news reporters, I think, who use it as a sort of audible punctuation mark in a very long sentence) don't use it to mean a lot. In fact some people don't like it at all. ;-) Many speakers just acquire it as a sort of verbal tic, and say things like 'Tom asked Dick as to why he had hit Harry' - which is unnecessarily wordy.
But as mmasny said, we really need more context if you'd like us to explain how it's used in a particular case.