My guess is that you have a stuck reversing valve or something like that. This would case it to stay in AC mode. This would overcool the indoor coil and case it to freeze. Along the same lines, it could be a problem with the defrost control board. The outdoor coil can freeze up during heating mode. To avoid this, the unit puts itself into defrost mode (flips the reversing valve to AC mode and pulls heat from inside the house to heat the outdoor coil). During defrost, the aux. electrical heating strips will kick on so that the air blowing in the house wouldn't be cold.
I would have a tech come look at it. You can also post the problem over on hvac-talk.com. They have a lot of hvac pros on there. They are anti-DIY over there, but could probably tell you what they think it might be (but they probably won't help you fix it unless it was something simple (like a dirty filter)).
One thing that you can do is feel the refrig lines at the outdoor unit with the unit running (after things have thawed out). One should be quite warm and the other will be closer to room temperature (still warm compared to outside). If the lines are cold (especially if colder than outside temp), this would indicate that you are stuck in AC mode.