This is a good question, and not easily answered. I will do my best to help you based on my opinion of the difference.
A task is something that needs to be done, and in many cases is part of an overall assignment. For example, let's say that you have a job and your employer (boss) gives you an assignment. Your assignment is to clean and organize the warehouse. Within this assignment are many tasks. These tasks may include sweeping the warehouse floor, washing any windows that are in the warehouse, throwing away unused boxes, removing any trash, buying new shelves to help you organize the inventory and so on.
Maybe if we look at this in outline form, you will be able to understand what I am trying to say...
Assignment - Clean and Organize the Warehouse
• Task #1 Sweep the floors
• Task #2 Wash the windows
• Task #3 Remove the trash
• Task #4 Buy new shelves
Again, this is just my opinion. There are other differences also, but this is the way I view the difference. I hope I've helped at least a little.