The hierarchically porous carbons (HPCs) were prepared by sol-gel selassembly technology in different surfactant concentrations and were used as the potential electrode for lithium oxygen batteries. The physical and electrochemical properties of the as-prepared HPCs were investigated by filed emission scanning electron microscopy (FE-SEM), transmission electron microscopy (TEM), nitrogen adsorption-desorption isotherm and galvanostatic charge/discharge. The results indicate that all of the HPCs mainly possess mesoporous structure with nearly similar pore size distribution. Using the HPCs as the electrode, a high discharge capacity for lithium oxygen battery can be achieved, and the discharge capacity increases with the specific surface area. Especially, the HPCs-3 oxygen electrode with CTAB concentration of 0.27 mol/L exhibits good capacity retention through controlling discharge depth to 800 mA·h/g and the highest discharge capacity of 2050 mA·h/g at a rate of 0.1 mA/cm2.