I am a non-EU citizen but I hold a Dutch residence permit which allows me to travel within the Schengen area. However, I am planning to fly from Hamburg (Germany) to Ghana, with my Dutch permit and I was wondering if that is possible. Do I need to fly from the Netherlands, because I am leaving the EU?
No, you don't need to exit the Schengen area through the country your residence permit is from. A holder of a residence permit from a Schengen country has the right to transit through the other Schengen states on his way to and from the issuing country.
Of course you also need to be allowed to enter Ghana, but that is independent of where you fly from.