Broadly, Military and Civil are the only two categories in which the Pilots can be classified on the basis of the roles performed by them. What are the similarities and differences in tasks performed by them?
As mentioned Commercial should really be "Civilian" which includes Private and Commercial. Lets assume that military includes the various branches that employ pilots (Navy, Air Force, Marines etc).
In the end of the day everyone flies a plane...
A chunk of military aviation is devoted to combat related missions, this is something a civilian will never see (at least as far as I know). This includes but is not limited to surveillance, escorts, combat and other military related missions.
The military operates troop transport and cargo planes much like commercial operations do and they have pilots who fly them. I would think the tasks are very similar since moving people and cargo is moving people and cargo whether for the military or a civilian organization.
The military obviously had access to flying some planes that would be tough to get into as a civilian (fighter jets mainly). One operation that Civilian pilots will never see is take off and landing on a carrier. That is unique to Navy operations and as far as I know there is no way to do it as a civilian or even train for it (unless you can buy a carrier).
As far as regulations go the military aircraft and pilots are subject to military regulations (in terms of up keep and things like that) and must adhere to those rules which I believe are different in some cases than the FARs that govern US commercial and Private operations. That being said, if flying in US airspace the same rules apply to military planes that apply to civilian planes.
The biggest difference is that most everything in commercial aviation is considered administrative in the military. The tactical employment of our aircraft, the non-administrative portions of flight, is what separates military sorties from commercial flights. This emphasis on tactical flying has also led to significantly different cultures between commercial and military aviation. There isn't a commercial pilot I would stand a chance against in a game of FAR/AIM trivia, but I also doubt they'd fare much better if the tables were turned and the questions were related to carrier operations. We are two separate organizations with two unique mindsets to flying.
Within commercial civilian flying the mission objective is to land safely at a destination. In operational flying in a 'deployment zone' the mission is to do many other things before you land somewhere safely. There are so many more factors to consider than just flying from A to B.
Areas of recent combat, rising threats, low-level flight, areas where fighting is imminent, mountain flying, attempting to minimise the impact on local population when you fly over their houses/vilages/cities, proximity to other air-assets that fly in the same mission. Just to name a few.
Even seemingly 'airline' types of transport in the military do have to consider many more factors during take-off and landing in a war-zone. They don't come with missile self-protection systems for fun.
Basic difference is training. A military pilot is trained to achieve assigned mission even if he has to endanger his life or aircraft, where as Civil pilot is trained to keep safety of his aircraft paramount as it has many other lives with him. Converting from Military flying to Civil Commercial flying, pilot finds it most difficult to adhere to follow strict safety regulations.