I hope I understood the question, but here is the short answer of what I found: For single error-detecting codes, the smallest possible is $n = 3$ for any local qudit dimension (except for qubits, in which case $n = 4$). For single error-correcting codes, the smallest possible is $n = 5$ for any local qudit dimension.
Recall the notation that an $((n,K,d))_q$ is a dimension $K$ quantum code embedded in $n$ qudits (each having local dimension $q$) that can detect up to $d-1$ errors and correct up to $(d-1)/2$ errors. We are looking for the smallest $n$'s such that an $((n,q,2))_q$ and an $((n,q,3))_q$ exist. The answer for $q = 2$ is given in the question (i.e. $n = 4$ and $n = 5$, respectively) so we focus on the cases when $q \geq 3$. The quantum Singleton bound states that an $((n,K,d))_q$ must satisfy $K \leq q^{n-2d+2}$. For $d = 2$ and $d = 3$, the bounds are $q^{n-2}$ and $q^{n-4}$ respectively, which means that the smallest $n$'s we can hope for are $n = 3$ and $n = 5$. There are codes satisfying these parameters, and I will present the case when $d = 3$ first since it is simpler.
Constructions for a $((5,q,3))_q$
The stabilizer construction for a $((5,2,3))_2$ can be generalized to construct a $((5,q,3))_q$. There is an analogue of the Pauli group for $\mathbb{C}^q$ [Wikipedia] generated by the matrices $$X = \sum_{k = 0}^{q-1} \vert{k+1}\rangle\langle{k}\vert, Z = \sum_{k = 0}^{q-1} \omega^k \vert{k}\rangle\langle{k}\vert,$$ and $\omega I_q$where $\omega = e^{2 \pi i/q}$. The matrices in this group satisfy similar properties to the usual Pauli matrices, and stabilizer codes in $(\mathbb{C}^q)^{\otimes n}$ can be constructed using the tensor product of these matrices as stabilizer generators. A choice of stabilizer generators given by the 5 cyclic permutations of $X Z Z^\dagger X^\dagger I$ results in a $((5,q,3))_q$ [EC Zoo].
Constructions for a $((3,q,2))_q$
Here are three constructions that each give various cases for $q \geq 3$ (and every case of $q$ is covered), but none covers every case by itself.
Stabilizer Codes. If $q \geq 3$ is odd, then the stabilizer code with stabilizer generators $XXX$ and $ZZZ^{q - 2}$ is a $((3,q,2))_q$. If $q$ is even, then the corresponding stabilizer code fails to detect some errors.
Orthogonal Latin Square Construction [1]. If $q \geq 3$ but $q \neq 6$, then a $((3,q,2))_q$ can be constructed from a pair of orthogonal Latin squares (OLS). A Latin square of order $q$ is a $q \times q$ array of symbols from $\{0,1,...,q-1\}$ where each symbol occurs exactly once in each row and column. Two Latin squares of order $q$ are orthogonal if the ordered pairs formed from corresponding cells of the two Latin squares are all distinct. Here is an example of a pair of OLS of order 3 and the array of order pairs:
120 | 120 | (1,1) (2,2) (0,0)
201 | 012 | (2,0) (0,1) (1,2)
012 | 201 | (0,2) (1,0) (2,1)
Given a pair of OLS, let $L_{ij}$ be the ordered pair formed from cell $(i,j)$ (so $L_{00} = (1,1)$ in the above example). Let $T_{ijkl}$ be a tensor with indices in $\{0,1,2,..,q-1\}$ where $T_{ijkl} = 1$ if $L_{ij} = (k,l)$ and $0$ otherwise. Define a code with basis vectors $$\vert{\psi_i\rangle} = \sum_{jkl} T_{ijkl} \vert{jkl\rangle}$$ for $0 \leq i \leq q - 1$. From the properties of $T_{ijkl}$, this code detects all single errors. It is known from combinatorics that a pair of OLS of order $q$ exists for all $q \geq 3$, except $q = 6$ in which case none exists [Wikipedia].
$((3,6,2))_6$ Euler code. The only case that has not been covered is when $q = 6$. A code with these parameters was found using a pair of orthogonal quantum Latin squares of order 6 [1,EC Zoo]. Since there can be no pair of OLS of order 6, this can been seen as a quantum solution to an unsolvable classical problem. Also, it appears that no stabilizer code with these parameters exists.