In order to study the effect of dust extinction on the afterglow of gamma-ray bursts (GRBs), we carry out numerical calculations with high precision based on rigorous Mie theory and latest optical properties of interstellar dust grains, and analyze the different extinction curves produced by dust grains with different physical parameters. Our results indicate that the absolute extinction quantity is substantially determined by the medium density and metallicity. However, the shape of the extinction curve is mainly determined by the size distribution of the dust grains. If the dust grains aggregate to form larger ones, they will cause a flatter or grayer extinction curve with lower extinction quantity. On the contrary, if the dust grains are disassociated to smaller ones due to some uncertain processes, they will cause a steeper extinction curve with larger amount of extinction. These results might provide an important insight into understanding the origin of the optically dark GRBs.