Your question is difficult to answer in that in a way they are the same, in that they are used to defend an area. An Earthwork is what is usually a collapsed fort. A ditch is dug, usually on a high spot (although it can be on an open area), and the earth is piled on the inside, it is likely that a fence type wall is built in front of the piled earth, the earth acts as a walkway, so that the defenders can hurl stones or spears, and be protected by the wall. These are also known as hillforts, and can be of different sizes. One of the largest being Maiden Castle, near Dorchester in Dorset.
I hope this answers your question?