We introduce a fermion-to-qubit mapping defined on ternary trees, where any single Majorana operator on an n-mode fermionic system is mapped to a multi-qubit Pauli operator acting nontrivially on ⌈log3(2n+1)⌉ qubits. The mapping has a simple structure and is optimal in the sense that it is impossible to construct Pauli operators in any fermion-to-qubit mapping acting nontrivially on less than log3(2n) qubits on average. We apply it to the problem of learning k-fermion reduced density matrix (RDM), a problem relevant in various quantum simulation applications. We show that using the ternary-tree 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 improves over existing schemes for determining qubit RDMs.