Fly Finnair or take the ferry? Trip is mid October.
I just returned from a tour of the Baltic countries. While in Tallinn several people made a day trip to Helsinki via ferry. After they returned their verdict was that they spent too much time in transit compared to the time they had in Helsinki. I can only think it would be the same in reverse. So if you are going to do it, it appears that flying would be the best choice.
Take the ferry. Some ferries are faster than others. The Talllink ferry, for example (which I took in 2016 from Tallinn to Helsinki - didn't go back to Tallinn) takes two hours one way. Are you really going to get to the airport in Helsinki (arrive an hour ahead of departure?), take the flight, and take the train back into Tallinn faster than that? I doubt it. Plus, the ferry will likely be a much more pleasant ride. (You do have to arrive at the ferry terminal some time before departure, too, not arrive the moment before the ferry departs, but it's still less stressful than going to the airport in my opinion.)
FYI, some ferries (like Tallink) use the west terminal in Helsinki, which is not in the center of town. (I took the tram from there into town.) I've read that the Viking line uses the main ferry terminal in Helsinki and is more scenic than the ferry into west terminal that I took, but it might take a little longer and cost a little more. You could take a different ferry line each direction.
The ferry. Considering all the hassle of checking in, security, travel to and from airports etc, flying will not be faster.
The total door-to-door time of flying would not be faster than the ferry. If you cannot get the high speed ferry, or it runs slow due to weather, just enjoy the ride.
My suggestion would be the fast ferry. It will take about 2 hours. And once you reach Tallinn, it's a small trip to the medieval centre. you could walk, take the bus or taxi.