Most banks offer foreign currency exchange services. You don't need to have an account with the bank to exchange your money. Call ahead and find out what services your local banks offer, and give them time to obtain Moroccan dirhams. Some banks offer walk-in services, but they're likely to carry only the most common foreign currencies such as pounds or euros.
Many foreign currency exchange services exist to change currency for travelers. Research the services available in your area and find a reputable service offering a good exchange rate for Moroccan dirhams. Some companies also offer services online, giving you a wider array of options.
Be careful about how much of your money you exchange for Moroccan currency. Morocco does not allow the export of Moroccan dirhams when you leave the country. It's possible to exchange your money back to U. S. dollars before leaving Morocco, but it's still better to plan ahead and exchange only as much money as you think you'll need. Once you're in Morocco, you'll be able to use credit or debit cards, ATMs, and traveller's checks in addition to cash.