Changing a function at some points without changing its Riemann integral Let $f:[a, b] \to\mathbb{R} $ be a bounded function. It is well known that neither the Riemann integrability of $f$ on $[a, b] $ nor the value of its integral is affected by changing its values in any manner at a finite number of points in $[a, b] $.
This is based on

Theorem: Let a function $f:[a, b]\to\mathbb{R} $ be bounded and let $D\subseteq [a, b] $. If $f(x) =0$ for all $x\in[a, b] \setminus D$ and $D$ is finite then $f$ is Riemann integrable on $[a, b] $ with integral $0$.

The proof is not difficult and is essentially based on showing that we can cover points of $D$ by a finite number of intervals with total length small.
The above result can be extended using a similar argument to the case when $D$ has a finite number of limit points like $D=\{1,1/2,\dots,1/n,\dots\}$. Also note that we can't have $D$ as a general countable set (Dirichlet function provides the counter-example where $D=[a, b] \cap\mathbb{Q} $).
My question is:

How large the set $D$ can be while still making the theorem above valid? Is there any characterization for sets like these?

Note: The corresponding problem for Lebesgue integrals is handled by sets of measure zero. 
 A: From A. D. R. Choudary & C. P. Niculescu, Real Analysis on Intervals (Springer India 2014), pp. 318-320:

For the next theorem, we need the concept of Jordan null set.  A set
  $X \subset \mathbb{R}$ is called a Jordan null set if for every $\varepsilon > 0,$
  there is a finite family of compact intervals $([a_k, b_k])_{k=1}^n$ such that
  $X \subset \bigcup_{k=1}^n[a_k, b_k]$ and $\sum_{k=1}^n(b_k - a_k) < \varepsilon$
  (In other words, if $X$ can be covered by a finite number of intervals of arbitrary small total length). [$\ldots$]
9.5.10 Theorem (Property of stability)
  Let $f, g \colon [a, b] \to \mathbb{R}$ be two bounded functions and let $X$ be a
  Jordan null subset of $[a, b]$ such that $f(x) = g(x)$ for all
  $x \in [a, b] \setminus X.$ If $f$ is Riemann integrable, then $g$ is Riemann
  integrable and $\int_a^bg(x)\,dx = \int_a^bf(x)\,dx.$
In other words, when dealing with bounded functions, changes on Jordan null sets
  influence neither the character of integrability nor the value of the integral.

I haven't transcribed the proof, but it's only just over a page long, so it might not be too much work to do so (copyright permitting).
A: $1_E$ indicates the function having value $1$ at all points in $E$ and value $0$ at all points not in $E$.
Let $f$ be defined on $[a,b]$.
If $f$ is bounded, take $M$ such that $|f|\le M$. Then $|f|\le M \cdot 1_{\{f \neq 0\}}$.
If $\{f \neq 0\}$ has content $0$, then $1_{\{f \neq 0\}}$ is integrable on $[a,b]$ with integral zero.
Finally, since $-|f| \le f \le |f|$, you get $\overline {\int}_a^b f = 0$
Applying it to $-f$, you get also $\underline {\int}_a^b f = 0$ so $f$ is integrable on $[a,b]$ with integral zero.
"Conversely":
Let $f$ be non negative and integrable on $[a,b]$ with integral zero.
Clearly $\{f\neq0\} = \bigcup _{n=1}^\infty \{f> \frac 1n\}\,$.
Since $\,\frac 1n \cdot 1_{\{f>\frac 1n\}} \le f$ for every $n$, you get $\overline{\int}_a^b 1_{\{f>\frac 1n\}}=0$ for every $n$.
Then $\{f>\frac 1n\}$ has content zero for every $n$ and $\{f\neq0\}$ has (Lebesgue) measure zero.
You can look also at this answer: note that a bounded set has content zero iff its closure has (Lebesgue) measure zero.
A: As discussed in comments the key concept here is the content or Jordan measure of a set. The discussion which follows will deal with bounded sets only and we will refrain from mentioning this explicitly.

Definition: Let $S$ be a set and $\mathcal{C} $ be a finite collection of intervals (of any nature: closed, open, half open etc) such that $$S\subseteq \bigcup\limits_{I\in\mathcal {C}} I$$ Then $\mathcal{C} $ is said to be a finite cover of $S$. The  outer content of $S$, denoted by $c_o(S) $, is defined to be the infimum of sum of lengths of intervals in a finite cover of $S$.

And we start with our first key result:

Theorem 1: Let $S\subseteq [a, b] $ and let the function $f:[a, b] \to\mathbb {R} $ be defined such that $f(x) =0$ for all $x\in[a, b] \setminus S$ and $f(x) =1$ for all $x\in S$. Then $$\overline {\int} _{a} ^{b} f(x) \, dx=c_o(S) $$

To establish the result we consider any partition $$P=\{x_0,x_1,x_2,\dots, x_n\} $$ of $[a, b] $ and form the upper Darboux sum $$U(f, P) =\sum_{k=1}^{n}M_k(x_k-x_{k-1})$$ By the definition of $f$ we have $$U(f, P) =\sum_{S\cap[x_{k-1},x_k]\neq\emptyset} (x_k-x_{k-1})$$ and clearly the sum of lengths of the intervals which contains points of $S$ is not less than $c_o(S) $. Hence $U(f, P) \geq c_o (S) $ for every partition $P$ of $[a, b] $.
Our proof will be complete if we can show that for any given $\epsilon >0$ we can find some partition $P$ of $[a, b] $ such that $U(f, P) <c_o(S) +\epsilon$. By definition of outer content we have a finite cover $\mathcal{C} $ of $S$ such that sum of lengths of intervals in $\mathcal {C} $ is less than $c_o(S) +\epsilon$. The end points of the intervals of $\mathcal{C} $ which lie in $[a, b] $ together with the end points of $[a, b] $ form a partition $P$ of $[a, b] $. And clearly the sum of lengths of subintervals of $P$ which contain points of $S$ does not exceed the sum of lengths of intervals in $\mathcal {C} $ and thus is less than $c_o(S) +\epsilon $. It follows that $U(f, P) <c_o(S) +\epsilon $.
Notice that the arguments are simple primarily because the number of intervals involved here is finite.
In almost similar fashion we can define inner content of a set $S$, denoted by $c_i(S) $, as the supremum of sum of lengths of a finite number of non-overlapping intervals whose union is contained in $S$. If $S$ does not contain any intervals (eg $S=\mathbb{Q} \cap[0,1]$) then clearly $c_i(S) =0$.
If $S\subseteq [a, b] $ then one can prove with some effort that $$c_i(S) =b-a-c_o([a, b] \setminus S) $$ And we have the counterpart to theorem 1 above as

Theorem 2: Let $S\subseteq [a, b] $ and let a function $f:[a, b] \to \mathbb {R} $ be defined as $f(x) =1$ for all $x\in S$ and $f(x) =0$ for all $x\in[a, b] \setminus S$. Then $$\underline{\int}_{a} ^{b} f(x) \, dx=c_i(S)$$

A set $S$ is said to be Jordan measurable if $c_i(S) =c_o(S) $ and the common value of these inner and outer contents is called the content or Jordan measure of set $S$ and denoted by $c(S) $.
Our theorems 1 and 2 now lead us to

Theorem 3: Let $S\subseteq [a, b] $ and let a function $f:[a, b]\to\mathbb {R} $ be defined as $f(x) =1$ for all $x\in S$ and $f(x) =0$ for all $x\in[a, b] \setminus S$. Then $f$ is Riemann integrable on $[a, b] $ if and only if $S$ is Jordan measurable and in that case $$\int_{a} ^{b} f(x) \, dx=c(S) $$

Of special interest are those sets which are of content zero. Since $c_i(S) \leq c_o(S) $ a set is of content zero if and only if its outer content is zero. Due to the theorems proved in this answer it is clear that the set $D$ in current question should be of content zero.

How does one recognize sets of content zero? Well, a finite set is of content zero. Another example is mentioned in question: if a set $S$ has a finite number of limit points then $S$ is of content zero.
We can generalize a little  bit here. Let $S'$ denote the set of limit points of $S$. Then $S'$ is said to be the derived set of $S$. And using induction we can say that $S^{(n)} $ is the $n$-th derived set of $S$ if $S^{(n)} $ is the derived set of $S^{(n-1)}$. A set $S$ is said to be of type $n$ if $S^{(n)}$ is non-empty and $S^{(n+1)}$ is empty. A set is said to be of first species if it is of type $n$ for some non-negative integer $n$ otherwise it is said to be of second species. It can be proved with some effort that every set of first species is of content zero. An obvious example of a set of second species is $\mathbb {Q} \cap [0,1]$.
Sets of content zero can be countable like $\{1,1/2,1/3,\dots\} $ as well as uncountable like the Cantor set.
Union of a finite number of sets is of content zero if each set in the union is of content zero. However the same can not be said in case of union of countable number of sets. This is a serious limitation while dealing with Riemann integrals as evident from the following

Theorem 4: Let $f:[a, b] \to \mathbb {R} $ be a bounded function. Then $f $ is Riemann integrable on $[a, b] $ if and only if for every $\epsilon>0$ the set $D_{\epsilon} (f) $ of points where the oscillation of $f$ is greater than or equal to $\epsilon $ is of content zero.

Since the set $D$ of discontinuities of $f$ can be considered as union $D=\bigcup\limits_{n=1}^{\infty}D_{1/n}(f)$ the above theorem says each $D_{1/n}(f)$ is of content $0$. But $D$ may or may not be so. This drawback of content forces us to look for some similar idea but one which is preserved under countable unions and leads us to the notion of measure as developed by Lebesgue.

Note: The answer above is based on the presentation given in David M. Bressoud's A Radical Approach to Lebesgue's Theory of Integration. 
