Yes, you can always remove your answer as long as it has not been accepted. Just hit the delete link below your answer, as you have found.
With regards to homework questions, it's my opinion that we are not here to police those explicitly. If the OP wants to cheat on his homework by having us do his work, he's ultimately only harming himself. Answers are always obvious when they are in front of you. Until you have to explain them. So any decent teacher will easily pick out such students who do not fully grasp what they have "written". I would not be too worried about that.
What is worrisome however is users answering questions which are not real questions. That is, straight forward copies of the assignments without any effort shown. Or questions which don't go beyond a "give me teh codez". We don't want those on the site. So simply don't answer those. (Feel free to flag them as "Not a real question") And if you don't answer, you'll have addressed the homework cheats as well.
A student who shows good effort is more than welcome to ask for guidance or help with a particular problem he faces. As any user can. So there is no need to specifically address students IMO.
Note: I only speak about SO here (given that it's where the questions were asked). I believe that there are other homework policies on other sites within the network, but I can't speak about those.