When X = pts, we know that the index of [D] equal to 0. What about X is not a point. Thanks
This question is answered, e.g., in Higson, Roe: Analytic KHomology. Proposition 12.2.4 states that if X is $Spin^c$, then the Khomology fundamental class [X] is not equal to zero. Since the Khomology fundamental class of X is defined by the Khomology class of any Dirac operator on any complex spinor bundle in the concordance class provided by the $Spin^c$structure on X and since there exist such Dirac operator which are invertible (e.g. the AtiyahSinger operator on any complete Riemannian Spinmanifold with uniformly positive scalar curvature [this is Lemma 12.1.2]), the answer to your question is: No, an invertible Dirac operator does not need to represent the zero element in Khomology. But nevertheless, there is something which we can say in that case: Remark 12.1.4 states that $[D] \in K_0(X)$ is mapped to zero under the homomorphisms $K_0(X) \to K_0(pt) \cong Z$ induced by crushing X to a point, if D is invertible, i.e. the index of D is zero. You have noted this already. Furthermore, if X is a connected, complete Riemannian manifold and D a symmetric, finite propagation speed elliptic operator on X which is invertible, than it defines a Khomology class for every coarse compactification $\bar X$ of X (see Definition 10.6.7), which restricts to the class [D] of D in $K^{p}(C_0(X))$ under the map induced by the inclusion $C_0(X) \to C(\bar X)$. Then it follows from the exactness of the sequence $$\cdots \to K^{p}(C(\bar X)) \to K^{p}(C_0(X)) \xrightarrow{\partial} K^{p+1}(C(\partial X)) \to \cdots$$ that $\partial [D] = 0 \in K^{p+1}(C(\partial X))$, where $\partial X := \bar X  X$. Remember that the Khomology of X is defined via $K_p(X) := K^{p}(C_0(X))$. 

