There's (at least) two ways to manage productivity:

Work the job, not the hours. That is, you set an amount of work to be done by a certain date. Hopefully, what you've set is reasonable, and it's entirely up to your employees how they spend their working day. They can spend the day fishing for all you care, provided the work gets done at night.

Many of the answers here make an assumption along those lines. But the work isn't getting done, and you know why. So you're going to have to fall back to:

While they're on work time, they work.

It is not micro-management to assert this, especially as a means to the end of getting some work done. They're paid to spend time on the activities their employer assigns them. They're not (I assume) paid per bug fixed or per deadline met. (If they are then there's an easy possible solution -- they're getting fewer results per person, so you're automatically paying them less and can use the money to hire more people). So they should do what they're paid to do, and you should make them see this.

You've told them that contributing to Stack Overflow is not an appropriate use of work time. They've continued doing it. They should either clock off while contributing to Stack Overflow and make up the time elsewhere, or else they should keep from answering questions entirely, according to how flexible you are about working hours for these workers.

Be firm. If they were down the pub together several hours between 9 and 6 every working day because "they are somewhat addicted to alcohol", then I doubt you'd hesitate, and you wouldn't be accused of micro-management. Contributing to Stack Overflow when you've specifically told them that it's not work, is their personal leisure activity. It's not appropriate for them to pursue it primarily in office hours.

One thing you should avoid, if at all possible, is directly monitoring their Stack Overflow usage (like, emailing them to say you've checked their profile). Firstly, it's counter-productive, since it encourages them to be sneaky. They might even create second accounts. Secondly, it harms the trust between you and the remote team. They're not currently trustworthy, but your first attempt to get them back to trustworthiness should be to get them to monitor for themselves how much time they're spending, and see for themselves that it's too much.

Once you've tried that, if they really are "addicted" (perhaps not clinically, but have made a habit they find hard to break but would like to), then you should probably take specialist advice on that. I don't feel qualified to advise on the specifics of how to help them break such habits once they've seen the problem, tried honestly to address it, and failed due to some form of compulsion they can't overcome.

I do feel qualified to say that it's perfectly legitimate for you to take an interest in how the people you manage spend the time that they're paid to work for the company. Since you've taken an interest and determined that this needs to stop, then if absolutely necessary, you should make a disciplinary issue of it. People can't work remotely if they can't be trusted to actually work.

For what it's worth, I track my work time in chunks anyway in order to fill in a timesheet so the company can assess the internal cost of projects. Sometimes, I look at Stack Overflow waiting for something to run. When I realise I've spent a chunk of time on Stack Overflow long after the thing has finished running, I count it as a break, and I make up the time. This works for me because I work flexi-time, and it gives me strong incentives to look at Stack Overflow only in short bursts during work and longer periods outside work. If your team flexes then it might work for them (with their co-operation, of course). If their working day is a more rigid 9-6 with lunch break, then their abstinence from Stack Overflow use will need to be more rigid too. And if you're happy for them to spend an hour a day on Stack Overflow, that's fine too, but they should set aside the time, work it as productively as they can in terms of developing their skills via answering Stack Overflow questions, and be prepared to report to you what they've achieved and how long it took, like any other work activity.

Also, be aware that before it was Stack Overflow it was Facebook, before that it might have been Usenet or LiveJournal. There are always things that can distract people from work. Provided that they're not intentionally slacking off, just allowing themselves to be distracted, they will probably appreciate some rules provided they aren't too extreme ("you'll be fired if I catch you on Stack Overflow again" is too extreme). Rules forbidding this bad behaviour will help them discipline themselves to avoid falling into it, provided they aren't literally addicted.