In answer to the title: Not at all
Let's take a quote from Dickens' novel A Christmas Carol:
“If I could work my will,every idiot who goes about with Merry Christmas’ on his lips should be boiled with his own pudding, and buried with a stake of holly through his heart.”
This quote was of course from the Christmas hating Ebenezer Scrooge.
However, if we quote this as coming from Dickens, someone not familiar with his book may assume that Dickens hated Christmas, which we have no evidence for. He may have written the words, but it isn't his quote. He is giving the words to a character.
But if we quote it to Ebenezer Scrooge, again someone not familiar with the name may assume they are a real person. So it seems we can't just quote one or the other. Someone made the point that if the character is really famous we can just quote their name, but that's not true. Not everyone will have heard of a character, and someone else made the point they won't be as famous in a couple of hundred years.
There have been discussions similar on English.SE and Writing.SE, but none give a definite answer.
However, one of the answers gives a link to this site. It reaches the conclusion at the bottom that:
The fair, honest and ethical way to quote a fictional character is to note the speaker first, then the book, play or movie, and finally the author.
This isn't an official guideline, but it seems good advice. So in the case of my example, like this:
“If I could work my will,every idiot who goes about with Merry Christmas’ on his lips should be boiled with his own pudding, and buried with a stake of holly through his heart.” - Ebenezer Scrooge in A Christmas Carol by Charles Dickens.
The character deserves to be connected to words they say, it defines who they are as a character. But we don't want to give the idea that they aren't fictional.
But a character usually does not express the ideas of the author. So we can't just say the author.
The best, and in my opinion fairest way to say both, and the novel.
In your example, the quote should go as follows:
"The truth. It is a beautiful and terrible thing, and should therefore be treated with great caution." - Albus Dumbledore in Harry Potter by JK Rowling
There is no definite answer, but I think this makes the most sense.
EDIT
After some comments, I'm going to clarify and expand on a couple of different contexts.
If all the audience know the character
If the audience definitely knows the character (e.g. If someone goes to a book meeting after everyone's read a book) then you can probably just quote the character. The audience will know they are a fictional person.
If you are quoting multiple times
The first time I would go with character, book, author. After that, the reader will know that the character isn't real, and you can just quote the character.
If the character is used as the author's 'mouthpiece'
Sometimes authors write a sort of biography, but use a character instead of themselves. In this case, and if you have to be absolutely sure this is the case, it would probably be best to quote the author, as that is their thought, not the character's.
In all other situations
Include all the information, author, character and book. If one person doesn't know the character is fictional, then you need to include all information, at least the first time.
Sources, and examples of sites that agree with the character, book, author format:
Reddit
It depends on the context in which you're giving the quote, I would generally quote the character, if I wasn't sure that everybody would know who I was talking about I would go on to cite the book title and author. The problem with just quoting the author on the matter when it's a character saying whatever it is you're quoting is that it might suggest that the character's opinion is the author's opinion. But that doesn't make any sense. It's not that Shakespeare loves Juliet, but rather he wrote about Romeo loving Juliet.
I agree with this, especially where it says 'if I wasn't sure that everybody would know who I was talking about I would go on to cite the book title and author.' and the Shakespeare/Juliet example
Yahoo
One answer:
I'm pretty sure it goes "Quote." Character. Work (title underlined). Author.
Another gives an alternate way:
As [character] said in [Book] by [Author], "QUOTE."
fansofrealitytv
I would think "Quote" - character in title by author. You have to credit the author of the words.
Here is a guide to citing fiction by Monmouth University. It doesn't say anything about quoting characters, but it does say the following:
A WORK OF FICTION BY A SINGLE AUTHOR:
Author’s Name. Title of Work. Publisher, Year.
TWO WORKS OF FICTION BY THE SAME AUTHOR:
Author’s Name. Title of Work. Publisher, Year.
Title of Work. Publisher, Year.
And I imagine it would include the character's name if it said about quoting a character.