Answer
$$\cot \theta + \ln \left| {1 - \cot \theta } \right| + C$$
Work Step by Step
$$\eqalign{
& \int {\frac{{{{\sec }^2}\theta }}{{{{\tan }^3}\theta - {{\tan }^2}\theta }}} d\theta \cr
& {\text{Write the integrand in terms of }}u \cr
& u = \tan \theta ,\,\,\,\,\,\,\,du = {\sec ^2}\theta d\theta \cr
& {\text{then}}{\text{,}} \cr
& \int {\frac{{{{\sec }^2}\theta }}{{{{\tan }^3}\theta - {{\tan }^2}\theta }}} d\theta = \int {\frac{{du}}{{{u^3} - {u^2}}}} \cr
& {\text{factoring the denominator}} \cr
& = \int {\frac{{du}}{{{u^2}\left( {u - 1} \right)}}} = \int {\frac{{du}}{{{u^2}\left( { - 1 + u} \right)}}} \cr
& \cr
& {\text{Use the Endpaper Integral Table to evaluate the integral by the formula 66}} \cr
& \left( {66} \right):\int {\frac{{du}}{{{u^2}\left( {a + bu} \right)}}} = - \frac{1}{{au}} + \frac{b}{{{a^2}}}\ln \left| {\frac{{a + bu}}{u}} \right| + C \cr
& {\text{then}}{\text{,}} \cr
& \int {\frac{{du}}{{{u^2}\left( { - 1 + u} \right)}}} = - \frac{1}{{\left( { - 1} \right)u}} + \frac{1}{{{{\left( { - 1} \right)}^2}}}\ln \left| {\frac{{ - 1 + u}}{u}} \right| + C \cr
& = \frac{1}{u} + \ln \left| {\frac{{u - 1}}{u}} \right| + C \cr
& \cr
& {\text{Write the integrand in terms of }}\theta ,\,\,\,\,{\text{substitute }}\tan \theta {\text{ for }}u \cr
& = \frac{1}{{\tan \theta }} + \ln \left| {\frac{{\tan \theta - 1}}{{\tan \theta }}} \right| + C \cr
& = \frac{1}{{\tan \theta }} + \ln \left| {1 - \frac{1}{{\tan \theta }}} \right| + C \cr
& = \cot \theta + \ln \left| {1 - \cot \theta } \right| + C \cr} $$