If you have an URL like this:
If someone creates a link on his website, but changes the name like this
that would cause duplicate content. Is it nessecary to check if the name in the url is the same as the real name of the question and if not do a 301 redirect to the correct URL?
I see Stackoverflow.com doesn't do a 301 redirect, but just accepts any name in the URL. Can this cause duplicate content or your ranking to drop? Is SO not affected by this?
I think this can be resolved with canonical meta tag.
Duplicate content does not "cause your ranking to drop", this is a myth. In the example you gave, the worst thing that'll happen is that the first URL wouldn't gain any page rank benefit from the (incorrect) link, since it is to a different URL. You want to try and avoid this sort of thing simply because if lots of people are linking to the same content at different addresses, the benefit you get from those links is split. There is no 'penalty'.
In my opinion the correct thing to do here is to check the name in the URL against the name in the database, and if it doesn't match, send a 404 (the link is wrong after all). This way people are unlikely to link to the wrong URL in the first place.
If this is an old site and you already have lots of inbound links to incorrect URLs, you might want to send 301s to the correct URLs instead so as not to dead end users.
Some further reading:
This won't cause duplicate content as long as you use a
<link rel="canonical">
element. For example, this question's<link rel="canonical">
element is:This element does not change even if you visit the page with a different slug at the end of the URL.
It tells Google that, even if it got to this page via a different URL, it's the same page as the canonical page (not a duplicate) and it should be counted as such.
More info: Official Google Webmaster Central Blog — Specify Your Canonical