Per the FAA FARs - Are there any rules governing a "change of who is the PIC during flight, and thus who can log hours? Say a friend and I go flying together - can we switch as PIC half way through and each log half the time? Also, would the time not spent as PIC (if it is possible to switch) be logged as total flight time in addition to the time spent as PIC?
@ymb1 is correct in that it does not matter who the legal pilot in command is per §1.1. What does matter is following the rules in §61.51(e).
(e) Logging pilot-in-command flight time. (1) A sport, recreational, private, commercial, or airline transport pilot may log pilot in command flight time for flights-
(i) When the pilot is the sole manipulator of the controls of an aircraft for which the pilot is rated, or has sport pilot privileges for that category and class of aircraft, if the aircraft class rating is appropriate;
(ii) When the pilot is the sole occupant in the aircraft;
(iii) When the pilot, except for a holder of a sport or recreational pilot certificate, acts as pilot in command of an aircraft for which more than one pilot is required under the type certification of the aircraft or the regulations under which the flight is conducted; or
(iv) When the pilot performs the duties of pilot in command while under the supervision of a qualified pilot in command provided—
If in your example both pilots are rated to fly that airplane on your license whether or not you have the required endorsements or ratings to act as the legal pilot in command you can log PIC time. It does not matter who the legal pilot in command is at that time. Both pilots will log the flight time as PIC and total time for the time you are the sole manipulator of the controls.
Other ways both pilots can log PIC time is where one pilot who is the safety pilot is the legal pilot in command while the other pilot who is flying the airplane and sole manipulator of controls is under simulated instrument flight.
Let me be very clear here. If both pilots were to log PIC time under this condition, and many pilots do, they are making the statement in their logbook that could get them in trouble later on. Let me explain, pilot A and B go out and fly together; Pilot A is under the hood and the other is the legal pilot in command. On another day, Pilot B is under the hood and the other is the legal pilot in command. Both pilots log exactly the same amount of flight time for both PIC and total time on these flights. At this point, a precedence is set.
What is that statement you are making in your logbook?
Who the legal pilot in command is for each flight. Read the regulation again. If the safety pilot logs PIC time they are accepting legal pilot in command responsibilities and all that goes with it. If the pilot under the hood has an incident or accident or airspace infraction the FAA will want to know who the legal pilot in command was during that flight. The logbooks tell the story regardless what the pilots say at that moment.
Title 14 → Chapter I → Subchapter A → Part 1 → §1.1
Pilot in command means the person who:
(1) Has final authority and responsibility for the operation and safety of the flight;
(2) Has been designated as pilot in command before or during the flight; and
(3) Holds the appropriate category, class, and type rating, if appropriate, for the conduct of the flight.
For both to log flight time, there are many different scenarios. If yours is not one of them, then the non-PIC is just a passenger, i.e. whoever has the stick (and qualified per point (3) above), can start the clock.