An earthquake with a preliminary magnitude of 5.4 struck 20 kms (12.4 miles) off the east coast of Japan on Wednesday night, the United States Geological Survey reported.