What is the best way to use this program?
It seems like DuoLingo keeps track of what I messed up on from previous modules and presents them to me in subsequent ones. So Is it better to keep repeating modules until I can do it without losing any hearts, or do I just keep moving forward regardless of how many hearts I earn?
I would keep moving forward. The point of the hearts is to make it so that you have to repeat yourself until you're ready to move on; once you've passed a lesson it means you're ready for something new. If there's particular vocabulary you're bad at or feel insecure about, I would recommend going to the Vocabulary section of the website, and clicking on Practice Weakest Words.
Think about short term and long term memory retention. All of us are different, some, like me, require repeating words and phrases until I'm so bored I just have to learn them. Some don't.
Think about your reason for learning the language. Is it to put a notch on yer recognition of being a cunning linguist or do you want to speak to yer gardener?, Find other people who appreciate Flamenco? Read classic novels?
Whatever, the difference between the depth and the width or yer study will inform you of the appropriate use of yer time.