We introduce a fermion-to-qubit mapping using ternary trees. The mapping has a simple structure where any single Majorana operator on an n-mode fermionic system is mapped to a multi-qubit Pauli operator acting nontrivially on log_3 (2n+1) qubits. We prove that the ternary-tree mapping is optimal in the sense that it is impossible to construct a Pauli operator in any fermion-to-qubit mapping which acts nontrivially on less than log_3 (2n+1) qubits. We apply this mapping to the problem of learning k-fermion reduced density matrix (RDM); a problem relevant in various quantum simulation applications. We show that using this mapping one can determine the elements of all k-fermion RDMs, to precision ε, by repeating a single quantum circuit for ~ (2n+1) k / ε^2 times. This result is based on a method we develop here that allows one to determine the elements of all k-qubit RDMs, to precision ε, by repeating a single quantum circuit for ~ 3k /ε^2 times, independent of the system size. This method improves over existing ones for determining qubit RDMs.