All the sentences are grammatically correct although there's something about using wrong and wrongly with do anything/something that seems to be causing your problem.
Your example with homework is clearer. Unlike you I don't think there is any difference in meaning between She did her homework wrong and She did her homework wrongly. Both wrong and wrongly are used as adverbs in these cases and modify the meaning of the verb to do. Both examples therefore mean The way she did her homework was wrong.
Wrong can also be used as an adjective (wrong country, wrong colour etc) and is actually used as such in The way she did her homework was wrong where it modifies the meaning of the noun way. Another way of saying it would be She did her homework the wrong way.
I think the difficulty arising from your original examples can be explained as follows:
Did I do anything wrong? You could rewrite this as Did I do a wrong thing? which is clearly using wrong as an adjective because it's modifying the noun thing.
Did I do anything wrongly? You could rewrite this as Did I do a thing wrongly? which is using wrongly as an adverb because it's modifying the verb do. Did I do a thing wrong? has the same meaning because in this case wrong is being used as an adverb.
Wrongly is more formal than the adverb wrong. Wrongly can be used before or after the verb e.g. I wrongly believed she was nice or I believed wrongly she was nice. Wrong is always used after the verb: I guessed wrong.