For sufficiently long-lived charged particles, one measures the helix-shaped track in an external magnetic field, and gets from this the 4-momentum (and hence the masss).
For very short-lived particles, one gets complex masses from resonance measurements.
Edit: Any mass of an unstable particle is complex and defined as the pole of a propagator. The mass of a particle like Higgs is determined quite indirectly, as it takes lots of scattering experiments to reliably determine the relevant cross sections. See https://arxiv.org/abs/1207.1347 for how to determine the Higgs mass from measurements. See also https://arxiv.org/abs/1112.3007.
Your question touches the question of ontology in particle physics. Historically we are used to be thinking of particles as tiny independent entities that behave according to some laws of motion. This stems from the atomistic theory of matter, which was developed some two thousand years ago from the starting point of what would happen if we could split matter in ever smaller parts. The old Greeks came to the conclusion that there had to be a limit to that splitting, hence the atom hypothesis was born.
This was just a philosophical idea, of course, until around the beginning of the 19th century we learned to do chemistry so well that it became obvious that the smallest chunks that matter can be split into seemed to be the atoms of the periodic table. A hundred years later we realized that atoms can be split even further into nuclei and electrons. What didn't change was this idea that each chunk had its own independent existence.
This idea ran into a deep crisis during the early 20th century when we discovered the first effects of quantum mechanics. It turns out that atoms and nuclei and electrons do not, at all, behave like really small pieces of ordinary matter. Instead, they are behaving radically different, so different, indeed, that the human imagination has a hard time keeping up with their dynamic properties.
For a while we were in a limbo regarding our description of nature at the microscopic scale. It seemed like we could cling to some sort of "little weird billiard ball with mass, charge, spin etc. properties" kind of theory for electrons, but as time went by, this became ever more hopeless. Eventually we discovered quantum field theory, which does away with the particle description completely, and with that all the ontological problems of the past century have disappeared.
So what's the new way of describing nature? It is a field description, which assumes that the universe is permeated by ONE quantum field (you can split it up into multiple components, if you like). This quantum field has local properties that are described by quantum numbers like charge. This one quantum field is subject to a quantum mechanical equation of motion which assures that some properties like charge, spin, angular momentum etc. can only be changing in integer (or half integer) quantities (in case of charge it's actually in quantities of 1/3 and 2/3 but that's a historical artifact). Moreover, this field obeys symmetry rules that leave the total sum of some of these quantities unchanged or nearly unchanged. Charges in particular can only be created on this field in pairs such that the total charge remains zero.
So now we can answer your question in the language of the quantum field: the electron gets its charge by the field allowing to create one positive charge state and one negative charge state at the same time, leaving its total charge zero. This process takes some energy, in case of the electron-positron pair a little over 1MeV. Every other property that is needed to uniquely characterize an electron is created in a similar way and at the same time. The elementary particle zoo is therefore nothing but the list of possible combinations of quantum numbers of the quantum field. If it's not on the list, nature won't make it (at least not in form of a real particle state). Our list is, of course, at best partial. There are plenty of reasons to believe that there are combinations of quantum numbers out there that we have not observed, yet, but which are still allowed.
Best Answer
Elementary particles, like photons and electrons, are not more elementary in the sense that there are underlying theories, such as quantum spin model on lattice, from which they can be derived as an effective approximation (see for example arXiv:hep-th/0302201).
In particular, the string-net condensation provides a unified origin for gauge interactions and Fermi statistics: Both elementary gauge bosons (such as photons, gluons) and elementary fermions (such as electrons, quarks) can emerge as quasi-particles in a quantum spin model on lattice if the quantum spin model has a "string-net condensed state" as its ground state. An comparison between the string-net approach and the superstring approach can be found here.
There is a falsifiable prediction from the string-net theory: all fermions (elementary or composite) must carry gauge charges (see cond-mat/0302460). The standard model contain composite fermions that are neutral for $U(1)\times SU(2)\times SU(3)$ gauge theory. So according to the string-net theory, the standard model is incomplete. The correct model should contain extra gauge theory, such as a $Z_2$ gauge theory. So the string-net theory predicts extra discrete gauge theory and new cosmic strings associated with the new discrete gauge theory.
The emergence approach may also produce (linear) quantum gravity from quantum spin models (see arXiv:0907.1203). However, the emergence approach (such as the string-net theory), so far, fail to produce the chiral coupling between the $SU(2)$ weak interaction and the fermions.