Informal:
* Oye, ¿qué tal? ¿Ya terminaste la tarea? This is a very common and natural way to say it. "Oye" is a casual "Hey," "¿qué tal?" means "What's up?" or "How's it going?", and "¿Ya terminaste la tarea?" means "Did you already finish your homework?"
Slightly more formal (but still casual):
* Hola, ¿qué tal? ¿Has terminado la tarea? This uses "Hola" (Hello) instead of "Oye," and the verb tense is slightly more formal ("Has terminado" instead of "Ya terminaste"). The overall tone is still informal but a bit more polite.
The best option depends on your relationship with the person you're talking to. For friends, the first option is perfect. For someone you're slightly less familiar with, the second might be a better choice.