Let $G$ be a connected graph on $n$ vertices and $D(G)$ be its distance matrix. The formula for computing the determinant of this matrix in terms of the number of vertices is known when the graph is either a tree or a unicyclic graph. In this work we generalize these results, obtaining the determinant of the distance matrix of any graph whose block decomposition consists of edges, unicyclic and bicyclic graphs.